This project is archived and is in readonly mode.
accepts_nested_attributes_for is using the :conditions hash from has_one association
-
José Valim
For me it makes complete sense to use the conditions hash, as you are creating an owner. If you want to create something which does not have :owner and :admin set to true, you should use another association.
However, those conditions should not be caught by mass assignment, they should pass free. So in one way or the other, it's bug. :) But probably quite easy to fix!
-
Eloy Duran
Could you create a test case for the ActiveRecord test suite which clearly isolates the problem?
-
Eloy Duran
- Assigned user set to Eloy Duran
-
Eloy Duran
- State changed from new to invalid
I can't seem to reproduce this on the current 2-3-stable branch:
class Project has_one :owner, :class_name => 'Author', :conditions => { :owner => true, :admin => true } accepts_nested_attributes_for :owner end # without Author attr_accessible project = Project.create! :owner_attributes => { :name => 'Bello' } p project.owner # => #<Author id: 980190963, name: "Bello", project_id: 980190963, owner: true, admin: true> # with Author attr_accessible :name project = Project.create! :owner_attributes => { :name => 'Bello' } p project.owner # => #<Author id: 980190963, name: "Bello", project_id: 980190963, owner: nil, admin: nil>The fact that it assigns the values from the :conditions hash is indeed intended behavior.