Skip to content

Instantly share code, notes, and snippets.

@abarrak
Forked from lappi-lynx/array_to_relation.rb
Created September 7, 2017 08:09
Show Gist options
  • Save abarrak/5043fec6cd8b9d7adb2984725a741db5 to your computer and use it in GitHub Desktop.
Save abarrak/5043fec6cd8b9d7adb2984725a741db5 to your computer and use it in GitHub Desktop.
Rails: Convert array into ActiveRecord Relation object
scope :with_scope, -> { where(id: ARRAY_COLLECTION.map(&:id)) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment