aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorJeremy Friesen <jeremy.n.friesen@gmail.com>2011-05-16 11:55:24 -0400
committerJeremy Friesen <jeremy.n.friesen@gmail.com>2011-05-24 13:52:48 -0400
commitf2a0dfc2985c008a618e1616f6cf9a4c54098c33 (patch)
treeae344124052201dce41dad55860b65b2916142a1 /activerecord/lib
parentae323a51f1dcf5529f34927cb91693a993416b07 (diff)
downloadrails-f2a0dfc2985c008a618e1616f6cf9a4c54098c33.tar.gz
rails-f2a0dfc2985c008a618e1616f6cf9a4c54098c33.tar.bz2
rails-f2a0dfc2985c008a618e1616f6cf9a4c54098c33.zip
Addresses an inconsistency in the ActiveRecord::Base.method_missing handling of dynamic finder methods and the passing of the &block parameter for :find_by_attributes.
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/base.rb2
-rw-r--r--activerecord/lib/active_record/relation/finder_methods.rb1
2 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 19a7965429..fa33f02ae0 100644
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -1052,7 +1052,7 @@ module ActiveRecord #:nodoc:
if match.finder?
options = arguments.extract_options!
relation = options.any? ? scoped(options) : scoped
- relation.send :find_by_attributes, match, attribute_names, *arguments
+ relation.send :find_by_attributes, match, attribute_names, *arguments, &block
elsif match.instantiator?
scoped.send :find_or_instantiator_by_attributes, match, attribute_names, *arguments, &block
end
diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb
index 4659563f33..12d0a0a370 100644
--- a/activerecord/lib/active_record/relation/finder_methods.rb
+++ b/activerecord/lib/active_record/relation/finder_methods.rb
@@ -259,6 +259,7 @@ module ActiveRecord
if match.bang? && result.blank?
raise RecordNotFound, "Couldn't find #{@klass.name} with #{conditions.to_a.collect {|p| p.join(' = ')}.join(', ')}"
else
+ yield(result) if block_given?
result
end
end