Rails acts_as_taggable_on Tag Link Filtering
I have a list of 'notes', and each note has some tags via acts_as_taggable_on. It's a great plugin, and the tags are working wonderfully.
What would be the best way to filter this list of notes by the tag that is clicked on?
Example:
<% @notes.each do |note| %>
<%= note.c开发者_高级运维ontent %>
<% note.tag_list.each do |tag| %>
<%= link_to tag, '#', :class => "tag" %>
<% end %>
<% end %>
What should I replace the '#' with in order to change or scope out @notes? Not too familiar with this.
EDIt: I want something just like StackOverFlow actually, how would I add parameters to the URL based on the link?
Thanks!
I believe I figured it out. Was just having an off-moment.
I can create a named route like:
match 'tags/:tag' => 'controller#index', :as => 'tag'
And that way I can get the parameter I need.
精彩评论