From de6a067078ade6d4c9775ebd9d05ebb94b3a6b54 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Mon, 30 Apr 2012 15:55:50 -0700 Subject: return value of block is returned --- activerecord/lib/active_record/relation/finder_methods.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'activerecord/lib/active_record') 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 -- cgit v1.2.3