explanation of polymorphic in rails

21 views
Skip to first unread message

Oto Iashvili

unread,
Dec 13, 2015, 8:43:08 PM12/13/15
to Ruby on Rails: Talk
Hi,
Does someone know rails polymorphic very well and can explain me how I can do something similar than polymorphic and change dynamically the table name for a polymorphic attribute.
I know already that normally you need a have a "_type" attribute to define the table name, but I would like to define my own way to retrieve to table name. I was trying with table_name="xxx" but it doesn't works

thanks

Frederick Cheung

unread,
Dec 14, 2015, 3:20:07 AM12/14/15
to Ruby on Rails: Talk
The foo_type column references a class name, not a table name. I am not aware of any alternative mechanism for controlling by how polymorphic associations are loaded (perhaps a concrete example might clarify things)

Fred

Reply all
Reply to author
Forward
0 new messages