Forum: Ruby on Rails acts_as_taggable help

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D9094da56083f39d42f3675403d65831?d=identicon&s=25 will (Guest)
on 2006-04-29 01:32
Ahoy, having a bit of difficulty w/ the acts as taggable GEM.
I was able to create a tagcloud, but now i want to filter items by tags.


in my controller i have

  def show_tagged_with
    <-- snip snip -->
    @items      = Item.find_tagged_with( :any => params[:tag_name])
    @categories = Category.find_all
    @tag_name   = params[:tag_name]
    @tagged_items = Item.tags_count(:limit => 100)
  end


IN the VIEW
<% @items.each do |item| %>
  <%= render :partial => 'list_stripes', :locals => { :item => item } %>
<% end %>

Where the partial _list_stripes.rthml is a list of items

    <td><%=h item.tag_names.join(" ") %></td>
    <td><%=h item.created_on %></td>
    <td><%=h item.category.name %></td>

But i get an error

"undefined method `tag_names' for #<Array:0x3673b08>"

any ideas?
30ee518e6fdc5b07e060775b5a542bdb?d=identicon&s=25 Jón Borgþórsson (jongretar)
on 2006-04-29 03:01
(Received via mailing list)
Example of what works. Convert for your needs.

in tags_controller.rb

  def info
    @name = params[:name]
    @tag = Tag.find(:first, :conditions => "name = '#{@name}'")
  end

in info.rhtml
<% for @item in @tag.tagged %>
	<%= render :partial => "render_item" %>
<% end %>

in the partial _render_item.rhtml
<br /><%= @ item.name -%>
<br /><%= @ item.description -%>


On 4/28/06, will <willwithskills@hotmail.com> wrote:
>     @tag_name   = params[:tag_name]
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>


--
This topic is locked and can not be replied to.