rails / protected_attributes

Protect attributes from mass-assignment in ActiveRecord models.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow :without_protection on parent.child.build(:type => 'MyStiClass')

jebw opened this issue · comments

Currently if a model is using attr_protected (instead of attr_accessible) - its impossible to use the Rails 4.0 inheritance syntax for generating Single Table Inheritance classes.

parent_class.child_association.build({ :type => 'MyStiType' }, :without_protection => true)

The without_protection => true option is honoured by attr_accessible, but the subclass_for_attributes? in inheritance.rb ignores this option, so still does checks against the attr_protected attributes + the defaults of 'id' and 'type'.

This means the type attribute cannot get assigned, removing the ability to create STI models.