diff options
author | Sean Griffin <sean@seantheprogrammer.com> | 2015-10-15 08:09:18 -0700 |
---|---|---|
committer | Sean Griffin <sean@seantheprogrammer.com> | 2015-10-15 08:09:18 -0700 |
commit | de92b06bca9e744525452dd83e13a784bcfb9d3e (patch) | |
tree | 4348dfc3a81f4843219259e6326b510ad0bd8f71 /activerecord/lib | |
parent | b6cf69ebcbf7372c61d38aa33baa7d0f4224679b (diff) | |
parent | b901a49473817339e892f6c237a365a361b0b2d7 (diff) | |
download | rails-de92b06bca9e744525452dd83e13a784bcfb9d3e.tar.gz rails-de92b06bca9e744525452dd83e13a784bcfb9d3e.tar.bz2 rails-de92b06bca9e744525452dd83e13a784bcfb9d3e.zip |
Merge pull request #21964 from Drenmi/enhancement/update-deprecation-message
Better deprecation warning for `ActiveRecord::Relation#update`
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/relation.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index 05bf87ab9d..392b462aa9 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -417,6 +417,13 @@ module ActiveRecord elsif id == :all to_a.each { |record| record.update(attributes) } else + if ActiveRecord::Base === id + id = id.id + ActiveSupport::Deprecation.warn(<<-MSG.squish) + You are passing an instance of ActiveRecord::Base to `update`. + Please pass the id of the object by calling `.id` + MSG + end object = find(id) object.update(attributes) object |