From 817c1825c15013fd0180762ac5c05a2e024a640d Mon Sep 17 00:00:00 2001 From: yui-knk Date: Sun, 15 Nov 2015 23:56:52 +0900 Subject: Except keys of `build_record`'s argument from `create_scope` in initialize_attributes If argument of `build_record` has key and value which is same as default value of database, we should also except the key from `create_scope` in `initialize_attributes`. Because at first `build_record` initialize record object with argument of `build_record`, then assign attributes derived from Association's scope. In this case `record.changed` does not include the key, which value is same as default value of database, so we should add the key to except list. Fix #21893. --- activerecord/test/models/bulb.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'activerecord/test/models/bulb.rb') diff --git a/activerecord/test/models/bulb.rb b/activerecord/test/models/bulb.rb index a6e83fe353..c1e491e5c5 100644 --- a/activerecord/test/models/bulb.rb +++ b/activerecord/test/models/bulb.rb @@ -1,6 +1,7 @@ class Bulb < ActiveRecord::Base default_scope { where(:name => 'defaulty') } belongs_to :car, :touch => true + scope :awesome, -> { where(frickinawesome: true) } attr_reader :scope_after_initialize, :attributes_after_initialize -- cgit v1.2.3