Add ActiveRecord::Base#ids - Close #5812 #6091

merged 1 commit into from Apr 30, 2012


None yet
4 participants

This patch adds a new method for plucking all the IDs from a relation. This is useful when you need ID's for API's.

Original issue here: #5812

wycats added a commit that referenced this pull request Apr 30, 2012

Merge pull request #6091 from twinturbo/add-ids
Add ActiveRecord::Base#ids - Close #5812

@wycats wycats merged commit 69c2307 into rails:master Apr 30, 2012

pixeltrix added a commit that referenced this pull request Apr 30, 2012

Fix PR #6091
1. ActiveRecord::Base is not ActiveRecord::Relation
2. The order of records from an SQL query is uncertain without an ORDER clause
3. Run your own tests when submitting a pull request

@ahawkins ahawkins referenced this pull request in rails-api/active_model_serializers Mar 7, 2013


Breaking changes on how id's are serialized #220

Nthalk commented on 9307616 Dec 12, 2013

Why is this necessary? Isn't hiding calls to all considered bad form?

Also, this prevents me from having a class method of def self.ids(ids); where(id: ids); end that can really dry up my models for batch queries.


dmathieu replied Dec 12, 2013

There's no "necessary" or not at this point, since this is a public method which has been around for two years. It can't just be removed.
You can easily solve your issue by using find_by_id though.

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