diff options
author | Sławosz Sławiński <slawosz@gmail.com> | 2011-07-23 21:35:16 +0200 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2011-08-13 16:22:16 -0700 |
commit | e7f7439d068f587db91e959ef803606cae9e7cc5 (patch) | |
tree | e0bff70a29eda8136c0e8502c8e8f146c9a0d8d9 /activerecord/lib/active_record/relation | |
parent | 5004aaffc1c2bf81dfd23178b8ad691f0cecef26 (diff) | |
download | rails-e7f7439d068f587db91e959ef803606cae9e7cc5.tar.gz rails-e7f7439d068f587db91e959ef803606cae9e7cc5.tar.bz2 rails-e7f7439d068f587db91e959ef803606cae9e7cc5.zip |
allow select to have multiple arguments
Diffstat (limited to 'activerecord/lib/active_record/relation')
-rw-r--r-- | activerecord/lib/active_record/relation/query_methods.rb | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index 1654ae1eac..792ffe1c5d 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -37,12 +37,15 @@ module ActiveRecord relation end - def select(value = Proc.new) + def select(*args, &blk) + if !block_given? && args.blank? + raise ArgumentError + end if block_given? - to_a.select {|*block_args| value.call(*block_args) } + to_a.select {|*block_args| blk.call(*block_args) } else relation = clone - relation.select_values += Array.wrap(value) + relation.select_values += args relation end end |