I’ve been using the
to_param
username
end
in my user model so that I can access users by /user/username (instead of ID)
I’m trying to make links to user listings (listings is a nested resource) with:
@listings represent a query on the Listing model
<% @listings.each do |listing| %>
<%= link_to 'Show', user_listings_url(listing.user_id, listing) %>
<% end %>
But its giving me the user_id instead and I tried querying the listing.user_id into the users model but it just returned and object and I can’t get the simple user/username/listing path to work :/ Any help? Should I not be using to_param?
try this:
this will link to
/user/username/listings/listing_id