I am using acts_as_taggable to add tags to a post in order to be able to show all posts with the specific tag. This worked fine for me with:
#in posts_controller.rb
def index
if params[:tag].present?
@posts = Post.tagged_with(params[:tag]).paginate(:page => params[:page])
else
@posts = Post.all.order("created_at DESC")
end
end
and displaying them in my index.html.erb with
<p> tags: <%= raw post.tags.map{ |t| link_to t.name, posts_path(tag: t.name)}.join(', ') %><p>
Now i want to display all tags in another view with <%=raw Post.tag_counts_on(:tags).map{|t| link_to t.name, posts_path(tag: t.name)}%>
and faced the problem that t.name
is no longer just the tag name but "/t.name\"
which is linking me to the wrong site.
Is there a way to solve this problem or maybe even a better solution to link all tags that i got?
Aucun commentaire:
Enregistrer un commentaire