diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-04-30 15:51:09 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-04-30 16:14:15 -0700 |
commit | f0182d5cb9755e2a8ef933ea6b93d5e42f6d367d (patch) | |
tree | 3979b48ecc211437f7924c4ee091391c5c5e50f5 /activerecord/lib/active_record | |
parent | 838101ae04be06138f1bd7418473092b92754293 (diff) | |
download | rails-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')
-rw-r--r-- | activerecord/lib/active_record/relation/finder_methods.rb | 2 |
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 |