I have an Activity model. It belongs_to :parent, :polymorphic => true
.
Does Rails use parent.class.name
, parent.model_name
or something else to populate the parent_type field?
I want a Presenter to behave like the parent object it wraps, and I need to override the right method.
Thanks.
I'm working with Rails 3.0.7 right now, and the polymorphic type is being defined in
active_record-3.0.7/lib/active_record/association.rb
, line 1773.So it looks like it is calling
class_name.underscore
and then appending "_type". This may be slightly different for rails 3.1, but this should be a good starting place.