May 13, 2015 by Daniel P. Clark

Rails: Don’t “pluck” Unnecessarily

Using pluck in Rails is both quick and efficient.  But there are cases where it’s not what you want to use.  For example if you’re selecting all users who have contacts, you might see something like this. User.where(id: Contact.pluck(:user_id)) Rails’ where method allows for Arrays of items for lookup so the above code might turn…

Continue Reading »