aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/base.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-06-25 11:47:37 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-06-25 11:47:37 +0000
commit302c23d5a6c1df4a5a9f373e545db5f8a894bdd6 (patch)
tree335ff85f5a4bc4873276cfbecace495d3ae33079 /activerecord/lib/active_record/base.rb
parent3eed3272d7fc79040b6eb3b8586be0d8875d8203 (diff)
downloadrails-302c23d5a6c1df4a5a9f373e545db5f8a894bdd6.tar.gz
rails-302c23d5a6c1df4a5a9f373e545db5f8a894bdd6.tar.bz2
rails-302c23d5a6c1df4a5a9f373e545db5f8a894bdd6.zip
Fixed Base#find to honor the documentation on how :joins work and make them consistent with Base#count #1405 [pritchie@gmail.com] Improved dynamic finder docs #1495 [laurel@gorgorg.org]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1510 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/base.rb')
-rwxr-xr-xactiverecord/lib/active_record/base.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 2d4501e678..5535f224c8 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -135,9 +135,11 @@ module ActiveRecord #:nodoc:
#
# == Dynamic attribute-based finders
#
- # Dynamic attribute-based finders are a cleaner way of getting objects by simple queries without turning to SQL. They work by
- # appending the name of an attribute to <tt>find_by_</tt>, so you get finders like <tt>Person.find_by_user_name, Payment.find_by_transaction_id</tt>.
- # 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>.
+ # Dynamic attribute-based finders are a cleaner way of getting 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>.
#
# 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
@@ -737,7 +739,7 @@ module ActiveRecord #:nodoc:
def construct_finder_sql(options)
sql = "SELECT * FROM #{table_name} "
- sql << ", #{options[:joins]} " if options[:joins]
+ sql << " #{options[:joins]} " if options[:joins]
add_conditions!(sql, options[:conditions])
sql << "ORDER BY #{options[:order]} " if options[:order]
add_limit!(sql, options)