Helper method to easily get GlobalIDs from an ActiveRecord scope without instantiating AR objects.
Useful for mass-creating ActiveJob jobs from a specific subset of your records.
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
$ gem install activerecord-pluck-globalid
pluck_globalid when you want to instantiate ActiveJob from a scope:
user_gids = User.where(active: true).pluck_globalid user_gids.each do |user_gid| UserWorker.perform_later(user_gid) end
This avoids costly AR objects which can consume significant memory in such cases.
- Fork it ( https://github.com/lfittl/activerecord-pluck-globalid/fork )
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Add some feature')
- Push to the branch (
git push origin my-new-feature)
- Create a new Pull Request