belongs_to + :inverse_of + accepts_nested_attributes_for causes stack overflow on save #2525

Closed
alexeymuranov opened this Issue Aug 14, 2011 · 10 comments

Projects

None yet

3 participants

@alexeymuranov

Here are the steps to reproduce:

  • Create an application with 2 models:
rails new assoc_test_app
cd assoc_test_app
rails generate model Person name:string
rails generate model Member person_id:integer
rake db:migrate
  • Edit the models:
class Member < ActiveRecord::Base
  belongs_to :person, :inverse_of => :member
  accepts_nested_attributes_for :person
end

class Person < ActiveRecord::Base
  has_one :member
end
  • Start console (rails c) and do:
m = Member.new
m.build_person(:name => 'John2')
m.person.save

This gives "SystemStackError: stack level too deep".

@jonleighton
Member

Which version of Active Record?

@alexeymuranov

activerecord (3.0.9)

@jonleighton
Member

Please can you try against 3.1 and report back whether the bug is still there.

@alexeymuranov

The bug is not present in rails 3.1.
Should i close this or should it be labelled 3.0.9?
Thanks!

@jonleighton
Member

Well, theoretically Rails 3.0.X is still receiving bug fixes, but realistically it probably won't be fixed unless you provide a patch yourself. So up to you really.

@alexeymuranov

I am sorry, i am quite new to rails and github.
How do i mark it for 3.0.X?
Can you do it please?

@jonleighton
Member

I've applied the 3-0-stable label, but I don't want to assign a 3.0.X milestone because that would imply that it should block a subsequent 3.0.X release, which it shouldn't.

@alexeymuranov

Thanks!

@alexeymuranov

Thanks for letting me know!

Alexey.

On 15 Feb 2012, at 07:01, Andy Pliszka wrote:

I submitted a pull request that fixes the issue

#5044


Reply to this email directly or view it on GitHub:
#2525 (comment)

@steveklabnik
Member

Since there are PR for this issue already, and since it's about 3.0-stable, I'm closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment