开发者

has_many :through and acts-as-taggable-on

How can I get all the tags for a model's associ开发者_运维问答ated 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?


Try looping over Network.tag_counts.


Try this:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜