Only yield block if given.

This commit is contained in:
Emilio Tagua
2010-06-24 13:17:24 -03:00
parent 2c203a9413
commit 4b5f417e63

View File

@@ -22,9 +22,9 @@ module ActiveRecord
end
class_eval <<-CEVAL, __FILE__, __LINE__ + 1
def select(*args, &block)
def select(*args)
if block_given?
to_a.select(&block)
to_a.select { |*block_args| yield(*block_args) }
else
new_relation = clone
value = Array.wrap(args.flatten).reject {|x| x.blank? }