This project is archived and is in readonly mode.
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
-
Ryan Bigg October 14th, 2010 @ 02:00 AM
- State changed from new to needs-more-info
- Importance changed from to Low
Please attach a patch to duplicate this issue in Rails.
-
Hung Le November 7th, 2010 @ 11:59 PM
We ran to a similar issue using Rails 3.0 and traced it down to having "accepted_nested_attributes_for" in both the parent and its associated model(s). The problem went away when we removed the statement in the associated models.
-
Santiago Pastorino February 9th, 2011 @ 12:32 AM
- State changed from needs-more-info to open
This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.
Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.
-
Santiago Pastorino February 9th, 2011 @ 12:32 AM
- State changed from open to stale
-
Stephan Kaag February 21st, 2011 @ 09:26 AM
- State changed from stale to open
This is still an issue.
See: https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets...
[state:open]
-
hemant February 26th, 2011 @ 06:30 PM
Santiago,
I've attached a patch that demonstrates test for this problem on master branch.
Also I could replicate the issue locally on 3.0.3 stable branch.
-
Joey March 20th, 2011 @ 02:12 AM
I am experiencing the same issue on the 3.0.5 stable branch with Ruby 1.9.2 p180.
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>