ruby - Properly set / match routes in routes.rb -
i've implemented basic tagging in app, posts can filtered tags.
there's route in routes.rb that
get 'tags/:tag', to: 'links#index', as: :tag
however, have url /tags lists tags (triggers index action in tag controller).
i've set route up
get 'tags' => 'tags#index'
in tag view have index.html.erb
<% @tags.each |tag| %> <div class="row"> <%= link_to tag.name, tag_path(tag) %> </div> <% end %>
the problem <%= link_to tag.name, tag_path(tag) %>
leads /tags/:id
instead of /tags/:tag
, doesn't work.
how set up?
add following to_param
method tag
model:
def to_param name end
Comments
Post a Comment