aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2012-04-30 15:51:09 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2012-04-30 16:14:15 -0700
commitf0182d5cb9755e2a8ef933ea6b93d5e42f6d367d (patch)
tree3979b48ecc211437f7924c4ee091391c5c5e50f5 /activerecord/lib/active_record/relation
parent838101ae04be06138f1bd7418473092b92754293 (diff)
downloadrails-f0182d5cb9755e2a8ef933ea6b93d5e42f6d367d.tar.gz
rails-f0182d5cb9755e2a8ef933ea6b93d5e42f6d367d.tar.bz2
rails-f0182d5cb9755e2a8ef933ea6b93d5e42f6d367d.zip
only yield to finder block if something is found
Diffstat (limited to 'activerecord/lib/active_record/relation')
-rw-r--r--activerecord/lib/active_record/relation/finder_methods.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb
index 416b55f5c5..36ef945b66 100644
--- a/activerecord/lib/active_record/relation/finder_methods.rb
+++ b/activerecord/lib/active_record/relation/finder_methods.rb
@@ -217,7 +217,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?
+ yield(result) if block_given? && result
result
end
end