{"action":"opened","issue":{"url":"https://api.github.com/repos/rails/rails/issues/18351","labels_url":"https://api.github.com/repos/rails/rails/issues/18351/labels{/name}","comments_url":"https://api.github.com/repos/rails/rails/issues/18351/comments","events_url":"https://api.github.com/repos/rails/rails/issues/18351/events","html_url":"https://github.com/rails/rails/issues/18351","id":53452020,"number":18351,"title":"Non-dirty serialized column on child marked as changed when serialize class_name is specified","user":{"login":"steakchaser","id":214311,"avatar_url":"https://avatars.githubusercontent.com/u/214311?v=3","gravatar_id":"","url":"https://api.github.com/users/steakchaser","html_url":"https://github.com/steakchaser","followers_url":"https://api.github.com/users/steakchaser/followers","following_url":"https://api.github.com/users/steakchaser/following{/other_user}","gists_url":"https://api.github.com/users/steakchaser/gists{/gist_id}","starred_url":"https://api.github.com/users/steakchaser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/steakchaser/subscriptions","organizations_url":"https://api.github.com/users/steakchaser/orgs","repos_url":"https://api.github.com/users/steakchaser/repos","events_url":"https://api.github.com/users/steakchaser/events{/privacy}","received_events_url":"https://api.github.com/users/steakchaser/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-01-05T21:46:26Z","updated_at":"2015-01-05T21:46:26Z","closed_at":null,"body":"Rails 4.2.0\r\n\r\nIn a parent -> child relationship where the child has a `serialize` field with the `class_name` option set, the child serialize field is being marked as having changed when in fact it has not.  This then results in the child record being saved every time the parent is saved; even though nothing on the child has actually changed.\r\n\r\nI believe this is related to #8328 \r\n\r\nTest to reproduce (based on AR test template):\r\n```ruby\r\nunless File.exist?('Gemfile')\r\n  File.write('Gemfile', <<-GEMFILE)\r\n    source 'https://rubygems.org'\r\n    gem 'rails', '4.2.0'\r\n    gem 'arel', '6.0.0'\r\n    gem 'sqlite3'\r\n  GEMFILE\r\n\r\n  system 'bundle'\r\nend\r\n\r\nrequire 'bundler'\r\nBundler.setup(:default)\r\n\r\nrequire 'active_record'\r\nrequire 'minitest/autorun'\r\nrequire 'logger'\r\n\r\n# This connection will do for database-independent bug reports.\r\nActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')\r\nActiveRecord::Base.logger = Logger.new(STDOUT)\r\n\r\nActiveRecord::Schema.define do\r\n  create_table :posts do |t|\r\n    t.string :title\r\n  end\r\n\r\n  create_table :comments do |t|\r\n    t.integer :post_id\r\n    t.text :array\r\n  end\r\nend\r\n\r\nclass Post < ActiveRecord::Base\r\n  has_many :comments, dependent: :delete_all\r\n\r\n  accepts_nested_attributes_for :comments\r\nend\r\n\r\nclass Comment < ActiveRecord::Base\r\n  belongs_to :post\r\n\r\n  serialize :array, Array\r\nend\r\n\r\nclass BugTest < Minitest::Test\r\n\r\n  # def test_association_stuff\r\n  #   post = Post.create!\r\n  #   post.comments << Comment.create!\r\n  #\r\n  #   assert_equal 1, post.comments.count\r\n  #   assert_equal 1, Comment.count\r\n  #   assert_equal post.id, Comment.first.post.id\r\n  # end\r\n\r\n  def test_dirty_tracking_for_serialized_columns\r\n    post = Post.create!\r\n    post.comments << Comment.create!\r\n\r\n    # Causes comment to be saved even though nothing has changed\r\n    post.save!\r\n    # Fails when class_name is specified for Comment serialize attribute\r\n    assert_empty post.comments.first.changed_attributes\r\n  end\r\nend\r\n```\r\n"}}