I have the following classes:
I encountered a similar problem few days ago. The inheritance column(i.e. type
) in a STI model is a protected attribute. Do the following to override the default protection in your Person
class.
Rails 2.3
class Person < ActiveRecord::Base
private
def attributes_protected_by_default
super - [self.class.inheritance_column]
end
end
Rails 3
Refer to the solution suggested by @tokland.
Caveat:
You are overriding the system protected attribute.
Reference:
SO Question on the topic