From a7e6e009c93302f77b7a601f53fe88d63210c433 Mon Sep 17 00:00:00 2001 From: Marcel Molina Date: Wed, 5 Dec 2007 17:29:27 +0000 Subject: 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 --- activerecord/CHANGELOG | 2 ++ activerecord/lib/active_record/base.rb | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index f4d2474178..ed5f482193 100644 --- a/activerecord/CHANGELOG +++ b/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] diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 1b76836de5..81ee16e380 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -118,7 +118,7 @@ module ActiveRecord #:nodoc: # 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 @@ module ActiveRecord #:nodoc: # 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 find_by_ or find_all_by_, 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 - # Person.find(:first, ["user_name = ?", user_name]), you just do Person.find_by_user_name(user_name). - # And instead of writing Person.find(:all, ["last_name = ?", last_name]), you just do Person.find_all_by_last_name(last_name). + # Person.find(:first, :conditions => ["user_name = ?", user_name]), you just do Person.find_by_user_name(user_name). + # And instead of writing Person.find(:all, :conditions => ["last_name = ?", last_name]), you just do Person.find_all_by_last_name(last_name). # # It's also possible to use multiple attributes in the same find by separating them with "_and_", so you get finders like # Person.find_by_user_name_and_password or even Payment.find_by_purchaser_and_state_and_country. So instead of writing - # Person.find(:first, ["user_name = ? AND password = ?", user_name, password]), you just do + # Person.find(:first, :conditions => ["user_name = ? AND password = ?", user_name, password]), you just do # Person.find_by_user_name_and_password(user_name, password). # # It's even possible to use all the additional parameters to find. For example, the full interface for Payment.find_all_by_amount -- cgit v1.2.3