How to override the attr_protected?

Posted by KandadaBoggu on Stack Overflow See other posts from Stack Overflow or by KandadaBoggu
Published on 2010-03-26T22:17:07Z Indexed on 2010/03/26 22:23 UTC
Read the original article Hit count: 219

I have STI implementation as follows:

class Automobile < ActiveRecord::Base
end

class Car < Automobile
end

class Truck < Automobile
end

class User < ActiveRecord::Base
  has_many :automobiles
  accepts_nested_attributes_for :automobiles
end

I am creating a list of automobiles for a user. For each automobile, the UI sets the type field and the properties associated with the automobile.While form submission, the type field is ignored as it is a protected attribute.

How do I work around this issue? Is there a declarative way to unprotect a protected attribute?

© Stack Overflow or respective owner

Related posts about activerecord

Related posts about ruby-on-rails