Remove a tag type from the view
- by user284194
I have an index view that lists all of the tags for my Entry and Message models. I would like to only show the tags for Entries in this view. I'm using acts-as-taggable-on.
Tags Controller:
def index
@letter = params[:letter].blank? ? 'a' : params[:letter]
@tagged_entries = Tagging.find_all_by_taggable_type('Entry').map(&:taggable)
#@tagged_messages = Tagging.find_all_by_taggable_type('Message')
#@tagged_messages = Tagging.find_all_by_taggable_type('Message').map(&:taggable)
@title = "Tags"
if params[:letter] == '#'
@data = Tag.find(@tagged_entries, :conditions => ["name REGEXP ?",
"^[^a-z]"], :order => 'name', :select => "id, name")
else
@data = Tag.find(@tagged_entries, :conditions => ["name LIKE ?",
"#{params[:letter]}%"], :order => 'name', :select => "id, name")
end
respond_to do |format|
flash[:notice] = 'We are currently in Beta. You may experience errors.'
format.html
end
end
tags#index:
<% @data.each do |t| %>
<div class="tag"><%= link_to t.name.titleize, tag_path(t) %></div>
<% end %>
I want to show only the taggable type 'Entry' in the view.
Any ideas? Thank you for reading my question.