ruby on rails 4 - undefined method `attr_accessible' with Mongoid -
i using rails 4.1.1, ruby 2.1, mongodb, mongoid wrapper, rails_admin creating admin interfaces
i know 'attr_accessible' no longer works rails4. have installed 'protected_attributes' gem. still no success still getting warning in console
[railsadmin] not load model company, assuming model non existing. (undefined method `attr_accessible' company:class)
so, rails admin not load class company because have defined attr_accessible in model. here company model.
class company include mongoid::document @@employees_strength = {0 => '0-10', 1 => '11-50', 2 => '51-100', 3 => '101-500', 4 => '501-1000', 5 => '1000+', 6 => '5000+'} field :name, type: string field :website, type: string field :domain_name, type: string field :strength, type: integer has_many :employees has_one :admin, :class_name => 'employee', :dependent => :destroy, :inverse_of => :organization #attr_accessible :name, :website, :domain_name, :strength#, :admin_attributes, :allow_destroy => true attr_accessible :admin_attributes accepts_nested_attributes_for :admin, :allow_destroy => true end
please can body can help? thanks
mongoid 4 (<= 4.0.2 @ time of writing) not know activemodel::massassignmentsecurity
module provided protected_attributes
gem.
as such must include behaviour in models manually e.g.
class somedocument include mongoid::document include activemodel::massassignmentsecurity field :some_field attr_accessible :some_field end
however, gets tedious pretty reasonable alternative include module mongoid::document
module before of models defined.
module mongoid module document include activemodel::massassignmentsecurity end end
Comments
Post a Comment