aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2014-03-13 11:47:12 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2014-03-13 11:47:12 -0700
commitd35f0033c7dec2b8d8b52058fb8db495d49596f7 (patch)
tree4aa39f75ec80d4e0d16bc1bc80aff0c0df71673b /activerecord/lib/active_record
parentd92ae6ccca3bcfd73546d612efaea011270bd270 (diff)
downloadrails-d35f0033c7dec2b8d8b52058fb8db495d49596f7.tar.gz
rails-d35f0033c7dec2b8d8b52058fb8db495d49596f7.tar.bz2
rails-d35f0033c7dec2b8d8b52058fb8db495d49596f7.zip
passing an instance of an AR object to `find` is deprecated
please pass the id of the AR object by calling `.id` on the model first.
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/relation/finder_methods.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb
index 180bc64e3a..c2b9dc08fe 100644
--- a/activerecord/lib/active_record/relation/finder_methods.rb
+++ b/activerecord/lib/active_record/relation/finder_methods.rb
@@ -421,7 +421,11 @@ module ActiveRecord
end
def find_one(id)
- id = id.id if ActiveRecord::Base === id
+ if ActiveRecord::Base === id
+ id = id.id
+ ActiveSupport::Deprecation.warn "You are passing an instance of ActiveRecord::Base to `find`." \
+ "Please pass the id of the object by calling `.id`"
+ end
column = columns_hash[primary_key]
substitute = connection.substitute_at(column, bind_values.length)