diff options
Diffstat (limited to 'activerecord/lib/active_record/attribute_methods/write.rb')
-rw-r--r-- | activerecord/lib/active_record/attribute_methods/write.rb | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/attribute_methods/write.rb b/activerecord/lib/active_record/attribute_methods/write.rb index fa01f832ac..62c5ce059b 100644 --- a/activerecord/lib/active_record/attribute_methods/write.rb +++ b/activerecord/lib/active_record/attribute_methods/write.rb @@ -15,10 +15,12 @@ module ActiveRecord def define_method_attribute=(name) safe_name = name.unpack("h*".freeze).first ActiveRecord::AttributeMethods::AttrNames.set_name_cache safe_name, name + sync_with_transaction_state = "sync_with_transaction_state" if name == primary_key generated_attribute_methods.module_eval <<-STR, __FILE__, __LINE__ + 1 def __temp__#{safe_name}=(value) name = ::ActiveRecord::AttributeMethods::AttrNames::ATTR_#{safe_name} + #{sync_with_transaction_state} _write_attribute(name, value) end alias_method #{(name + '=').inspect}, :__temp__#{safe_name}= @@ -38,6 +40,7 @@ module ActiveRecord end name = self.class.primary_key if name == "id".freeze && self.class.primary_key + sync_with_transaction_state if name == self.class.primary_key _write_attribute(name, value) end |