[Rails] 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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home