This project is archived and is in readonly mode.

#3761 open
twalpole

inverse_of causes infinite loop with accepts_nested_attributes_for

Reported by twalpole | January 21st, 2010 @ 02:43 AM

Given two classes

class A < ActiveRecord::Base
  belongs_to :b, :inverse_of=>:a
  accepts_nested_attributes_for :b
end

class B < ActiveRecord::Base
  has_one :a, :inverse_of=>:b
end

attempting to build and save via

a=A.new
a.attributes={:b_attributes=>{}}
a.save

creates an infinite loop and gnereates stack level too deep error. Removing the inverse_of or changing the direction of the belongs_to <=> has_one relationship makes it work correctly

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Pages