Skip to content

Commit

Permalink
Correcting the documentation which wrongly states that each dynamic f…
Browse files Browse the repository at this point in the history
…inder creates

method on the class. Only dynamic finders using <tt>scoped_by_*</tt> creates new
methods.
  • Loading branch information
Neeraj Singh committed Aug 2, 2010
1 parent d3eacf9 commit db0e3e5
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions activerecord/lib/active_record/base.rb
Expand Up @@ -966,17 +966,14 @@ def compute_table_name
end
end

# Enables dynamic finders like <tt>find_by_user_name(user_name)</tt> and
# <tt>find_by_user_name_and_password(user_name, password)</tt> that are turned into
# <tt>where(:user_name => user_name).first</tt> and
# <tt>where(:user_name => user_name, :password => :password).first</tt>
# respectively. Also works for <tt>all</tt> by using <tt>find_all_by_amount(50)</tt>
# that is turned into <tt>where(:amount => 50).all</tt>.
# Enables dynamic finders like <tt>User.find_by_user_name(user_name)</tt> and
# <tt>User.scoped_by_user_name(user_name). Refer to Dynamic attribute-based finders
# section at the top of this file for more detailed information.
#
# It's even possible to use all the additional parameters to +find+. For example, the
# full interface for +find_all_by_amount+ is actually <tt>find_all_by_amount(amount, options)</tt>.
#
# Each dynamic finder, scope or initializer/creator is also defined in the class after it
# Each dynamic finder using <tt>scoped_by_*</tt> is also defined in the class after it
# is first invoked, so that future attempts to use it do not run through method_missing.
def method_missing(method_id, *arguments, &block)
if match = DynamicFinderMatch.match(method_id)
Expand Down

0 comments on commit db0e3e5

Please sign in to comment.