Reputation: 19305
I installed the Acts as taggable on plugin to my 'Post' model, however I'm unable to call up a list of posts tagged with certain tag.
Here's what I have in show.
<%= link_to tag.name, posts_path(:view =>'tag', :tag => tag.name) %><% end %>
Except when I click on it, it shows all posts. I want it to show just the posts tagged with that keyword...what am I doing wrong here?
Thanks for your help
Upvotes: 0
Views: 418
Reputation: 5335
Here is what I ended up doing...
<% job.tags.each do |tag| %>
<div class="tag"><%= link_to(tag, jobs_path(tag: tag.name), method: :get) %></div>
<% end %>
if params[:tag]
@search_term = params[:tag]
@jobs = Job.tagged_with(@search_term)
end
Upvotes: 0
Reputation: 3255
Modify your controller code so that it reads something like:
@posts = Post.tagged_with(params[:tag], :on => 'tags')
Upvotes: 1