aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorEgor Lynko <flexoid@gmail.com>2012-05-30 00:36:28 +0300
committerEgor Lynko <flexoid@gmail.com>2012-06-25 18:30:15 +0300
commit359592bba6cb85b43ca8945917b1ca57fa7494a9 (patch)
tree215a7c8cd7c1074b0d8b6e64ece9785e89b854bd /activerecord/lib/active_record
parent24a4cc741a948cd4a01d172a3bfbd68c509b4448 (diff)
downloadrails-359592bba6cb85b43ca8945917b1ca57fa7494a9.tar.gz
rails-359592bba6cb85b43ca8945917b1ca57fa7494a9.tar.bz2
rails-359592bba6cb85b43ca8945917b1ca57fa7494a9.zip
exists?(false) returns false
`FinderMethods#exists?` finder method now returns *false* with the *false* argument
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/relation/finder_methods.rb12
1 files changed, 6 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb
index c91758265b..e6a67b76fe 100644
--- a/activerecord/lib/active_record/relation/finder_methods.rb
+++ b/activerecord/lib/active_record/relation/finder_methods.rb
@@ -170,19 +170,19 @@ module ActiveRecord
# Person.exists?(['name LIKE ?', "%#{query}%"])
# Person.exists?(:name => "David")
# Person.exists?
- def exists?(id = false)
- id = id.id if ActiveRecord::Model === id
- return false if id.nil?
+ def exists?(conditions = :none)
+ conditions = conditions.id if ActiveRecord::Model === conditions
+ return false if !conditions
join_dependency = construct_join_dependency_for_association_find
relation = construct_relation_for_association_find(join_dependency)
relation = relation.except(:select, :order).select("1 AS one").limit(1)
- case id
+ case conditions
when Array, Hash
- relation = relation.where(id)
+ relation = relation.where(conditions)
else
- relation = relation.where(table[primary_key].eq(id)) if id
+ relation = relation.where(table[primary_key].eq(conditions)) if conditions != :none
end
connection.select_value(relation, "#{name} Exists", relation.bind_values)