Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use :pluck #26

Closed
wants to merge 2 commits into from
Closed

Use :pluck #26

wants to merge 2 commits into from

Conversation

sturgill
Copy link
Contributor

Rails 3.2 introduced the pluck method. This prevents you from having to load up full AR model instances just to grab the id field.

@mceachen
Copy link
Collaborator

Thanks, but I want to keep Rails 3.0 and 3.1 support, at least for now.

If you want to add a version-aware switch (only do pluck if it's available), that would be great!

@sturgill
Copy link
Contributor Author

Whether or not this is worth incorporating (given backwards compatibility to pre-pluck days) will depend on the average size of the found sets. Significant gains can happen when there are lots of records as AR is bypassed whenever possible (so those running Rails 3.2.x). But if the average returned set is only a handful of records, this is probably near worthless.

I promise not to be offended if you don't want to incorporate this yet... ;)

@mceachen
Copy link
Collaborator

mceachen commented Nov 5, 2012

I merged your diff with .try—but .try doesn't shield you from missing methods, only from nil receivers.

.respond_to? is what you wanted.

Thanks for the pluck!

@mceachen mceachen closed this Nov 5, 2012
@sturgill
Copy link
Contributor Author

sturgill commented Nov 5, 2012

Yes, you're right - got a little fast with the fingers.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 490a91a on sturgill:master into * on mceachen:master*.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants