質問

I am using the acts_as_taggable_on gem to try and add tags to my posts. I am encountering a problem on the tag pages. They aren't properly filtered by tag but instead just show all the posts. This is odd because in my debugger 'Post.tagged_with(params[:tag])' returns just the posts with the particular tag.

Here is the posts#index:

 def index
  if params[:tag]
   @posts = Post.tagged_with(params[:tag])
  else
   @posts = Post.all
  end
 end

and here is the link to the tag's page:

<%= raw post.tag_list.map { |t| link_to t, tag_path(t) }.join(', ') %>
役に立ちましたか?

解決

Oops, ok easy fix. In my posts#index i was wasn't even calling posts. I fixed it with this

<% @posts.each do |post| %>
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top