Alexey Muranov
2011-Aug-14  14:10 UTC
belongs_to + :inverse_of + accepts_nested_attributes_for causes stack overflow on save
Hello, i have just submitted a bug report, but maybe anybody has some
experience with this problem?
Here are the steps to reproduce the error:
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
Set up an association:
  class Member < ActiveRecord::Base
    belongs_to :person, :inverse_of => :member
    accepts_nested_attributes_for :person
  end
  class Person < ActiveRecord::Base
    has_one :member
  end
Now, in concole (rails c) do:
  m = Member.new
  m.build_person(:name => ''John2'')
  m.person.save
This produces "SystemStackError: stack level too deep".
Without :inverse_of it works fine.
Is there a reason not to use :inverse_of with
accepts_nested_attributes_for, or is it just a bug?
Thanks.
Alexey.
-- 
Posted via http://www.ruby-forum.com/.
-- 
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
Alexey Muranov
2011-Aug-14  16:49 UTC
Re: belongs_to + :inverse_of + accepts_nested_attributes_for causes stack overflow on save
This bug is not present in rails 3.1! -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.