Browse files

update AR::FinderMethods#exists?(false) example [ci skip]

  • Loading branch information...
1 parent 456489f commit debb3a178f9863d542feed037915c08dd6978089 Francesco Rodriguez committed Jun 28, 2012
Showing with 7 additions and 5 deletions.
  1. +7 −5 activerecord/lib/active_record/relation/finder_methods.rb
View
12 activerecord/lib/active_record/relation/finder_methods.rb
@@ -146,17 +146,18 @@ def all
to_a
end
- # Returns true if a record exists in the table that matches the +id+ or
- # conditions given, or false otherwise. The argument can take five forms:
+ # Returns +true+ if a record exists in the table that matches the +id+ or
+ # conditions given, or +false+ otherwise. The argument can take six forms:
#
# * Integer - Finds the record with this primary key.
# * String - Finds the record with a primary key corresponding to this
# string (such as <tt>'5'</tt>).
# * Array - Finds the record that matches these +find+-style conditions
# (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.
+ # (such as <tt>{color: 'red'}</tt>).
+ # * +false+ - Returns always +false+.
+ # * 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.
@@ -168,7 +169,8 @@ def all
# Person.exists?(5)
# Person.exists?('5')
# Person.exists?(['name LIKE ?', "%#{query}%"])
- # Person.exists?(:name => "David")
+ # Person.exists?(name: 'David')
+ # Person.exists?(false)
# Person.exists?
def exists?(id = false)
id = id.id if ActiveRecord::Model === id

0 comments on commit debb3a1

Please sign in to comment.