aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/base.rb
diff options
context:
space:
mode:
authorScott Taylor <scott@railsnewbie.com>2009-01-31 21:32:49 -0500
committerDavid Heinemeier Hansson <david@loudthinking.com>2009-02-05 20:51:06 +0100
commit5a8f764661bcdf9c6ce503c0ff343a1970deb1bb (patch)
treed834baa2819042a33226ca2931b54b0e4308415f /activerecord/lib/active_record/base.rb
parent6db78e8c02442080d2be93faeeb42be97b09fb53 (diff)
downloadrails-5a8f764661bcdf9c6ce503c0ff343a1970deb1bb.tar.gz
rails-5a8f764661bcdf9c6ce503c0ff343a1970deb1bb.tar.bz2
rails-5a8f764661bcdf9c6ce503c0ff343a1970deb1bb.zip
Add ActiveRecord::Base.exists? with no args [#1817 state:committed]
Signed-off-by: David Heinemeier Hansson <david@loudthinking.com>
Diffstat (limited to 'activerecord/lib/active_record/base.rb')
-rwxr-xr-xactiverecord/lib/active_record/base.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index f9168c8dc2..9f9fbd8b37 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -663,7 +663,7 @@ module ActiveRecord #:nodoc:
# Returns true if a record exists in the table that matches the +id+ or
- # conditions given, or false otherwise. The argument can take four forms:
+ # conditions given, or false otherwise. The argument can take five forms:
#
# * Integer - Finds the record with this primary key.
# * String - Finds the record with a primary key corresponding to this
@@ -672,6 +672,7 @@ module ActiveRecord #:nodoc:
# (such as <tt>['color = ?', 'red']</tt>).
# * Hash - Finds the record that matches these +find+-style conditions
# (such as <tt>{:color => 'red'}</tt>).
+ # * No args - Returns false if the table is empty, true otherwise.
#
# For more information about specifying conditions as a Hash or Array,
# see the Conditions section in the introduction to ActiveRecord::Base.
@@ -685,7 +686,8 @@ module ActiveRecord #:nodoc:
# Person.exists?('5')
# Person.exists?(:name => "David")
# Person.exists?(['name LIKE ?', "%#{query}%"])
- def exists?(id_or_conditions)
+ # Person.exists?
+ def exists?(id_or_conditions = {})
connection.select_all(
construct_finder_sql(
:select => "#{quoted_table_name}.#{primary_key}",