Search code examples
ruby-on-railsrubyohm

Ohm, find all records from array of ids


I am looking for a way to find all Ohm affiliated objects with one query, by feeding it an array of attributes that are indexed. In Mongoid, this is done with something like:

Foo.any_in(:some_id => [list_of_ids])

ActiveRecord has the find_all family of methods.

I essentially want to be able to pull N records from the data store without calling find() 30 times individually.


Solution

  • You can pass find an array or list of IDs:

    Foo.find(1,2,3) or Foo.find([1,2,3])