search for: massassignment

Displaying 2 results from an estimated 2 matches for "massassignment".

2012 Jul 09
10
attr_accessible on some properties + attr_protected on others makes class 'open-by-default'
...me I should post it here, so here it is.) If you set attr_accessible on some properties in an ActiveRecord-descended class, and then attr_protected on others - the class becomes ''default-open'' - if any properties are missed or added later, they will be accessible by default to MassAssignment. This undoes the entire point of having put attr_accessible in one''s class. Two possible solutions - #1) ''default-closed'' - the attr_protected statements will either be ignored, or just used to override attr_accessiblefor a particular property. #2) ''explicit-...
2012 Apr 27
1
Can't mass-assign protected attributes even if I use attr_accessible
...9;m working on a Rails 3.2.2 application which has JSON APIs and I use a CLI client for inserting some data. It works fine except for the Author model. When I try to create a new post (Post belongs_to :author and Author has_many :posts) I get the following error : <h1> ActiveModel::MassAssignmentSecurity::Error in PostsController#create </h1> <pre>Can''t mass-assign protected attributes: name</pre> I did lots of searches on the topic but I found no working solution :-( I use attr_accessible to avoid MassAssignent errors and it works for all others models...