tags_controller.rb:
def index
@title = "tags"
@posts = Post.tag_counts.collect do |tag|
Post.tagged_with(tag).first(:order => "updated_at DESC")
end
@posts.uniq!
end
tags/index.html.rb:
<%= render 'latest' %>
_latest.html.erb:
<%- for post in @posts -%>
<%- post.tags.each do |t| -%>
<%= link_to t.name, tag_path(t) %>
<%- end -%>
<%- end -%>
My goal is to show only the latest 10 posts, each with a unique tag. The current code above shows unique tags, but more than 10. Can anyone help?