Posted 3 months ago. Visible to the public. Repeats.

Shortcut for getting ids for an ActiveRecord scope

You can use .ids on an ActiveRecord 4+ scope to pluck all the ids of the relation

Copy
User.where("users.name LIKE 'Foo Bar'").ids # same as User.where("users.name LIKE 'Foo Bar'").pluck(:id)

Once an application no longer requires constant development, it needs periodic maintenance for stable and secure operation. makandra offers monthly maintenance contracts that let you focus on your business while we make sure the lights stay on.

Owner of this card:

Avatar
Martin Schaflitzl
Last edit:
3 months ago
by Besprechungs-PC
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Martin Schaflitzl to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more