I'm writing some tricky polymorphic relationships to handle tagging.
I have a Tag
model, and a Tagging
model which belongs_to a polymorphic taggable
.
I have an Item
model, which has_many :taggings, :as => :taggable
, and has_many :tags, :through => :taggings
, so that I can call @item.tags
.
This is all working ok.
I want to bring another model into the mix - a Store
which has_many :items
. I want to be able to find all tags associated with all items in the store using @store.tags
.
Here's what I have:
class Store < AR::Base
has_many :items
has_many :tags, :through => :items, :source => :taggings
However, this returns all of the taggings
associated with items in the store, not the actual tags.
How do I get specify that the store has_many tags, through items, through taggings?
Can post more info if needed - trying to prevent information overload! Thanks :)