aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-09-07 00:38:51 -0700
committerJon Leighton <j@jonathanleighton.com>2011-09-07 00:38:51 -0700
commitdb8d54ebf5102d2f30c0c332ea852ad284702ef3 (patch)
tree5700b21c7dc088f9506f49e76dfb249826004e2f /activerecord/lib/active_record/relation
parent4edf6ea0eae9cb8be46a2e963e047eb89a0f5531 (diff)
parentd48dd18bb2a3d0c46708a9ee217909783b997cb2 (diff)
downloadrails-db8d54ebf5102d2f30c0c332ea852ad284702ef3.tar.gz
rails-db8d54ebf5102d2f30c0c332ea852ad284702ef3.tar.bz2
rails-db8d54ebf5102d2f30c0c332ea852ad284702ef3.zip
Merge pull request #2485 from akaspick/exists_fix
fix exists? to return false if passed nil (which may come from a missing
Diffstat (limited to 'activerecord/lib/active_record/relation')
-rw-r--r--activerecord/lib/active_record/relation/finder_methods.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb
index 83d650d3f4..7eeb3dde70 100644
--- a/activerecord/lib/active_record/relation/finder_methods.rb
+++ b/activerecord/lib/active_record/relation/finder_methods.rb
@@ -184,7 +184,9 @@ module ActiveRecord
# Person.exists?(:name => "David")
# Person.exists?(['name LIKE ?', "%#{query}%"])
# Person.exists?
- def exists?(id = nil)
+ def exists?(id = false)
+ return false if id.nil?
+
id = id.id if ActiveRecord::Base === id
join_dependency = construct_join_dependency_for_association_find