allow select to have multiple arguments ie. Post.select(:id,:name,:author) #2276

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
5 participants
Contributor

slawosz commented Jul 26, 2011

I tried to call select with multiple arguments few times, and now I added it. Such API is much more natural than string for me.

claco commented Jan 17, 2012

Funny. I just noticed it's documented as working this way, but doesn't:

http://api.rubyonrails.org/classes/ActiveRecord/QueryMethods.html#method-i-select

This method will also take multiple parameters:

Model.select(:field, :other_field, :and_one_more)
=> [#<Model field: "value", other_field: "value", and_one_more: "value">]

Yeah docs are wrong - but it does work

Model.select([:field, :other_field, :and_one_more]).first
=> #<Model field: value, other_field: value, and_one_more: value>

@danshultz The code is documented correctly. https://github.com/rails/rails/blob/master/activerecord/lib/active_record/relation/query_methods.rb#L111

You should submit a PR if you want this functionality.

@steveklabnik can you close this?

Owner

rafaelfranca commented Apr 29, 2012

Closing it now. Please use the documented API.

@twinturbo I'll review this further and decide if it's worth pursing but as a note - this issue (of documentation) was actually resolved 2 days after the comments on the pull request.

e95e932

Thanks,
Dan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment