I have a chained polymorphic relationship. I will try to describe it
as best as I can.
Imagine:
Group (polymorphic)
\
|
Tag (polymorphic)
\
|
Article
The idea being I can TAG many ARTICLES. I can also GROUP many TAGS.
And enjoy using both TAG and GROUP in more creative ways. I also use
proxy classes (GROUPABILITY and TAGABILITY) to encapsulate the
relationships. Both Groupability and Tagability are where
the :polymorphic => true statement resides. Then I use has_many with
a :through statement to do most of the relational work.
Group
\
> Groupability (real polymorphic)
|
Tag
\
> Tagability (real polymorphic)
|
Article
After creating this relationship, the Tagabilty works just fine. The
Tagable_id and Tagable_type field are populated correctly. The
Groupability appears to work fine HOWEVER while the groupable_id field
is populated correctly , the groupable_type field remains nil. I
(believe) I have checked all my syntax which looks correct.
Are there any known bugs with this type of chained polymorphism or
some trick I am missing? Is the belongs_to on the polymorphic =
true line, simply appended with “_type” to determine the proper field
in the database to set the value? Is there a manual way of setting the
_type field for the proper class? How can I debug this when I am
getting no errors?
Steve Woolley
[email protected]