Reputation: 51
I am trying to use correctly :anchor in my Rails app but I can't get it work correctly.
my example:
<% = link_to('Artist Page', artists_path(artist, :anchor => 'ranking')) %>
and the link I get:
/artists.1-young-the-giant#ranking
instead of:
/artists/1-young-the-giant#ranking
So I am getting a "dot" instead or a "forward slash".
I have search a lot inside stackoverflow and I see similar examples with same result.
Any idea?
I am using the last version of Rails. Thank you so much.
Upvotes: 0
Views: 1065
Reputation: 3080
Try
<% = link_to('Artist Page', artist_path(artist, :anchor => 'ranking')) %>
artist_path
should be singular as you're not querying the index action.
Check out this part of Rails guides for more info:
http://guides.rubyonrails.org/routing.html#path-and-url-helpers
These are the paths generated for you when you use the resource keyword in your routes:
artists_path returns /artists
new_artist_path returns /artists/new
edit_artist_path(:id) returns /artists/:id/edit
artist_path(:id) returns /artists/:id
Upvotes: 4