I am using Ruby on Rails 3 and I would like to change the default type-column name used by a polymorphic association.
For example, if I have this class:
class Comment < ActiveRecord::Base
...
end
and I implement for that a polymorphic association, I would like to use the type-column names comm_id
and comm_type
instead of commentable_id
and commentable_type
. Is it possible? If so, what I have to change for the Comment class?
There's no way in Rails API to override the default column name used for polymorphic associations.
Take a look at this answer for a possible solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With