Skip to content

Commit 94e7be3

Browse files
committed
Remove ActiveRecord patch
Patching ActiveRecord is dangerous. Furthermore, query optimization is out of scope of this gem. This fixes Travis builds for Rails 4.0 and 4.1.
1 parent 43d5a88 commit 94e7be3

File tree

2 files changed

+0
-20
lines changed

2 files changed

+0
-20
lines changed

lib/rails-settings/setting_object.rb

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,5 @@ def _set_value(name, v)
7676
def _target_class
7777
target_type.constantize
7878
end
79-
80-
# Patch ActiveRecord to save serialized attributes only if they are changed
81-
if ActiveRecord::VERSION::MAJOR < 4
82-
# https://github.com/rails/rails/blob/3-2-stable/activerecord/lib/active_record/attribute_methods/dirty.rb#L70
83-
def update(*)
84-
super(changed) if changed?
85-
end
86-
else
87-
# https://github.com/rails/rails/blob/4-0-stable/activerecord/lib/active_record/attribute_methods/dirty.rb#L73
88-
def update_record(*)
89-
super(keys_for_partial_write) if changed?
90-
end
91-
end
9279
end
9380
end

spec/queries_spec.rb

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,5 @@
9797
user.settings(:dashboard).update_attributes! :foo => 'bar'
9898
}.to perform_queries(1)
9999
end
100-
101-
it "should not touch database if there are no changes made" do
102-
expect {
103-
user.settings(:dashboard).update_attributes :theme => 'pink'
104-
user.settings(:calendar).update_attributes :scope => 'all'
105-
}.to perform_queries(0)
106-
end
107100
end
108101
end

0 commit comments

Comments
 (0)