views:

11

answers:

2

How can I get all the tags for a model's associated models using acts-as-taggable-on?

I have the following models, and want to build a list of tags that the network's associated offers have:

class Network < ActiveRecord::Base
  has_many  :offers
end

class Offer < ActiveRecord::Base
  acts_as_taggable
  belongs_to  :network
end

How do you do that?

A: 

@network.offers.map{|o| o.tags }.flatten.compact ?

Yannis
A: 

Try looping over Network.tag_counts.

Joost Schuur