[Rails] nested forms and attr_accessable
Rails 2.3.5
I am working on a nested form that assigns roles to users through a
table called clearances. I have attr_acessable turned off globally in
an initializer:
ActiveRecord::Base.send(:attr_accessible, nil)
I have this set in clearance.rb
attr_accessible(:description,
:effective_from,
:role_id,
:superceded_after,
:user_id)
And this is what params looks like after the submit button is
selected:
{"user"=>{"id"=>"146"}, "commit"=>"Commit Changes", "_method"=>"put",
"action"=>"update", "clearance"=>[{"id"=>"122", "description"=>"Just a
test", "effective_from"=>"2009-01-01"}, {"role_id"=>"178",
"effective_from"=>"2010-01-21 00:00:00 -0500", "user_id"=>"146"}],
"controller"=>"user_roles"}
But this:
if @user.update_attributes!(params[:user])
neither raises an error nor updates the rows. I have tried this with
and without the attr_accessible initializer and the results are the
same ether way.
I read that this should work with nested rows but I cannot determine
what I might be doing wrong. Can anyone see what might be happening?
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home