Don't mark the store as changed if an attribute isn't changed. #6934

Merged
merged 1 commit into from Jul 3, 2012

Conversation

Projects
None yet
2 participants
@kennyj
Contributor

kennyj commented Jul 2, 2012

If an attribute isn't modified, I think we shouldn't mark the store as changed.

@rafaelfranca

View changes

activerecord/lib/active_record/store.rb
@@ -58,8 +58,10 @@ def store_accessor(store_attribute, *keys)
keys.each do |key|
define_method("#{key}=") do |value|
initialize_store_attribute(store_attribute)
- send(store_attribute)[key] = value
- send :"#{store_attribute}_will_change!"
+ if value != send(store_attribute)[key]

This comment has been minimized.

@rafaelfranca

rafaelfranca Jul 2, 2012

Member

I think we should cache the send(store_attribute)

@rafaelfranca

rafaelfranca Jul 2, 2012

Member

I think we should cache the send(store_attribute)

This comment has been minimized.

@kennyj

kennyj Jul 3, 2012

Contributor

Thanks @rafaelfranca .
I updated it.

@kennyj

kennyj Jul 3, 2012

Contributor

Thanks @rafaelfranca .
I updated it.

rafaelfranca added a commit that referenced this pull request Jul 3, 2012

Merge pull request #6934 from kennyj/fix_store
Don't mark the store as changed if an attribute isn't changed.

@rafaelfranca rafaelfranca merged commit 55456ad into rails:master Jul 3, 2012

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