GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
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
Merge pull request #6091 from twinturbo/add-ids
Add ActiveRecord::Base#ids - Close #5812
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
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.
def self.ids(ids); where(id: ids); end
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.