diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-04-30 15:55:50 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-04-30 16:14:15 -0700 |
commit | de6a067078ade6d4c9775ebd9d05ebb94b3a6b54 (patch) | |
tree | 3e4ccf64a99ca7e0630e514dbdf27cac8b3eb0f9 /activerecord/lib | |
parent | f0182d5cb9755e2a8ef933ea6b93d5e42f6d367d (diff) | |
download | rails-de6a067078ade6d4c9775ebd9d05ebb94b3a6b54.tar.gz rails-de6a067078ade6d4c9775ebd9d05ebb94b3a6b54.tar.bz2 rails-de6a067078ade6d4c9775ebd9d05ebb94b3a6b54.zip |
return value of block is returned
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/relation/finder_methods.rb | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb index 36ef945b66..1ceb1949a4 100644 --- a/activerecord/lib/active_record/relation/finder_methods.rb +++ b/activerecord/lib/active_record/relation/finder_methods.rb @@ -217,8 +217,11 @@ 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 - result + if block_given? && result + yield(result) + else + result + end end end |