I am wondering if I am only having this problem. To define this, I created two very simple models.
# user.rb class User < ActiveRecord::Base has_one :role, :inverse_of => :user accepts_nested_attributes_for :role end # role.rb class Role < ActiveRecord::Base belongs_to :user, :inverse_of => :role accepts_nested_attributes_for :user end
In the rails console, an attempt to update a simple attribute of the Role class fails if the User model is loaded.
Loading development environment (Rails 3.2.2) 1.9.3-p194 :001 > Role.first.update_attribute(:role_type, 72) => true 1.9.3-p194 :002 > Role.first.tap {|r| r.user}.update_attribute(:role_type, 72) SystemStackError: stack level too deep from /Users/enelson/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/workspace.rb:80 Maybe IRB bug!
If I remove one of the accepts_nested_attributes directives, this problem will disappear. I think the easy answer here is "OK, then why don't you get rid of one of them?" The problem is that you will need to rewrite many existing pages in the application, and if there is another fix or workaround, I would like to hear about it.
source share