Skip to content
Browse files

Documentation for find incorrectly omits the :conditions option from …

…various examples. Closes #7923 [mattwestcott]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8295 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent d7e9780 commit a7e6e009c93302f77b7a601f53fe88d63210c433 Marcel Molina committed
Showing with 6 additions and 4 deletions.
  1. +2 −0 activerecord/CHANGELOG
  2. +4 −4 activerecord/lib/active_record/base.rb
View
2 activerecord/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Documentation for find incorrectly omits the :conditions option from various examples. Closes #7923 [mattwestcott]
+
* Document options and add examples for update. Closes #7985 [fearoffish]
* Document options and add examples for delete. Closes #7986 [fearoffish]
View
8 activerecord/lib/active_record/base.rb
@@ -118,7 +118,7 @@ def initialize(errors)
# question mark is supposed to represent. In those cases, you can resort to named bind variables instead. That's done by replacing
# the question marks with symbols and supplying a hash with values for the matching symbol keys:
#
- # Company.find(:first, [
+ # Company.find(:first, :conditions => [
# "id = :id AND name = :name AND division = :division AND created_at > :accounting_date",
# { :id => 3, :name => "37signals", :division => "First", :accounting_date => '2005-01-01' }
# ])
@@ -184,12 +184,12 @@ def initialize(errors)
# Dynamic attribute-based finders are a cleaner way of getting (and/or creating) objects by simple queries without turning to SQL. They work by
# appending the name of an attribute to <tt>find_by_</tt> or <tt>find_all_by_</tt>, so you get finders like Person.find_by_user_name,
# Person.find_all_by_last_name, Payment.find_by_transaction_id. So instead of writing
- # <tt>Person.find(:first, ["user_name = ?", user_name])</tt>, you just do <tt>Person.find_by_user_name(user_name)</tt>.
- # And instead of writing <tt>Person.find(:all, ["last_name = ?", last_name])</tt>, you just do <tt>Person.find_all_by_last_name(last_name)</tt>.
+ # <tt>Person.find(:first, :conditions => ["user_name = ?", user_name])</tt>, you just do <tt>Person.find_by_user_name(user_name)</tt>.
+ # And instead of writing <tt>Person.find(:all, :conditions => ["last_name = ?", last_name])</tt>, you just do <tt>Person.find_all_by_last_name(last_name)</tt>.
#
# It's also possible to use multiple attributes in the same find by separating them with "_and_", so you get finders like
# <tt>Person.find_by_user_name_and_password</tt> or even <tt>Payment.find_by_purchaser_and_state_and_country</tt>. So instead of writing
- # <tt>Person.find(:first, ["user_name = ? AND password = ?", user_name, password])</tt>, you just do
+ # <tt>Person.find(:first, :conditions => ["user_name = ? AND password = ?", user_name, password])</tt>, you just do
# <tt>Person.find_by_user_name_and_password(user_name, password)</tt>.
#
# It's even possible to use all the additional parameters to find. For example, the full interface for Payment.find_all_by_amount

0 comments on commit a7e6e00

Please sign in to comment.
Something went wrong with that request. Please try again.