diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-09-07 00:38:51 -0700 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-09-07 00:38:51 -0700 |
commit | db8d54ebf5102d2f30c0c332ea852ad284702ef3 (patch) | |
tree | 5700b21c7dc088f9506f49e76dfb249826004e2f /activerecord/lib/active_record/relation | |
parent | 4edf6ea0eae9cb8be46a2e963e047eb89a0f5531 (diff) | |
parent | d48dd18bb2a3d0c46708a9ee217909783b997cb2 (diff) | |
download | rails-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.rb | 4 |
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 |