Skip to content

Instantly share code, notes, and snippets.

@mfazekas
Last active August 29, 2015 14:05
Show Gist options
  • Save mfazekas/fc7cf36804efe19f0ce9 to your computer and use it in GitHub Desktop.
Save mfazekas/fc7cf36804efe19f0ce9 to your computer and use it in GitHub Desktop.
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
gem 'arel', github: 'rails/arel'
gem 'sqlite3'
gem 'byebug'
GEMFILE
system 'bundle'
end
require 'bundler'
Bundler.setup(:default)
require 'active_record'
require 'minitest/autorun'
require 'logger'
# This connection will do for database-independent bug reports.
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Schema.define do
create_table :users do |t| end
create_table :employees do |t| t.integer "user_id" end
end
class User < ActiveRecord::Base
has_one :employee
accepts_nested_attributes_for :employee
end
class Employee < ActiveRecord::Base
belongs_to :user
accepts_nested_attributes_for :user
end
class BugTest < MiniTest::Unit::TestCase
def test_changed_for_autosave_inf_loop
u = User.create!
e = Employee.create!(user:u)
u.employee=e
e.save!
end
end
@kurko
Copy link

kurko commented Jan 3, 2015

I have this problem on 4.2. Unfortunately, the issue is locked and I can't comment. I applied the patch locally and it fixes the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment