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
@slawosz
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

This comment has been minimized.

Show comment Hide comment
@claco

claco 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">]

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">]

@danshultz

This comment has been minimized.

Show comment Hide comment
@danshultz

danshultz Jan 17, 2012

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>

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>
@ahawkins

This comment has been minimized.

Show comment Hide comment
@ahawkins

ahawkins Apr 29, 2012

@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?

@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?

@rafaelfranca

This comment has been minimized.

Show comment Hide comment
@rafaelfranca

rafaelfranca Apr 29, 2012

Owner

Closing it now. Please use the documented API.

Owner

rafaelfranca commented Apr 29, 2012

Closing it now. Please use the documented API.

@danshultz

This comment has been minimized.

Show comment Hide comment
@danshultz

danshultz Apr 29, 2012

@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

@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