Backport Bugfix: Stack Overflow (3-0-stable) #5044

merged 2 commits into from Apr 30, 2012


None yet

5 participants


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

I run into the same issue. There is a cyclic autosave for belongs_to/has_one when using accepts_nested_attributes. It causes stack overflow.


Do you mind adding a test for this? Also, does it occur on the master branch?

  1. I added a test.
  2. I just verified that the issue does not occur on the master branch.

@jonleighton @tenderlove should this be applied to 3-0, could you please check? ^^

@tenderlove tenderlove commented on the diff Apr 30, 2012
@@ -140,6 +140,23 @@ def #{type}(name, options = {})
+ def define_non_cyclic_method(name, reflection, &block)
+ define_method(name) do |*args|
+ result = true; @_already_called ||= {}
tenderlove Apr 30, 2012 Ruby on Rails member

Does this need to be an instance variable?

@wycats wycats merged commit 51582fe into rails:3-0-stable Apr 30, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment