I am using Ruby on Rails 3.0.9 and I would like to know in which cases (that is, for which methods) the attr_accessible method has effect. For example, if I use
attr_accessible :name, :surname
it will care to not assign those attribute values when you use the new(...) method for the User.new(params[:user]) statement.
But what other methods it will take care? Can I run correctly, for example, methods as where(...) and exists?(...) without that the attr_accessible will take effect?
If you use
attr_accessible, the model will prevent mass assignment of those columns which are not included in theattr_accessiblelist. The methods affected are those ofmass assignmentlikenew,create,update_attributes,attributes=etc. All other functions will work, even single assignment like this:So, there should not be any problem for using them in
where,exists?etc.