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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -