Trying to Link from a User Type Directory Page to a User Type Gallery Page
I have two user types by 'identification_id', let's call them Red and Blue. Each user type has listings which all show on the home page. I created a shop page for each user type that shows all of their specific listings, linking to this shop page from the show page for each of their listings. I also created a gallery page for each user type that shows all static pictures that specific user type uploaded. I link to that user type gallery page also from the show page for their listings. I then created a global directory page by user type and have 2 links in my main navigation Red and Blue, so I can click Red directory and view a list of all Red users types with identification_id: "red". Same set up for Blue. Now I want to link each user in the Red Directory directly to their gallery page. In my directory_controller I have "def Red @users = User.where(identification_id: "1").order("created_at DESC")". I added to the view page "<%= link_to "View Gallery", gallery_path(@user.user.id) %>", but getting an error: "NoMethodError in Listings#red" with "undefined method `user' for nil:NilClass". When I add to the controller: "@user = User.find(params[:id])" I get the error: "Couldn't find User with 'id'=". I always get stuck at this point, isn't the @user defining the id which then links to the "identification_id" for this user and so the link should work to the gallery_path? I'm guessing I can't have 2 methods for Red for @user/@users? How do I define Red so that I get their "identificaton_id" to create the directory list and then also connect to the gallery page? Hoping this makes sense.
Posted over 4 years ago by