Skip to content

Instantly share code, notes, and snippets.

@Porta
Created March 5, 2014 14:16
Show Gist options
  • Select an option

  • Save Porta/9367970 to your computer and use it in GitHub Desktop.

Select an option

Save Porta/9367970 to your computer and use it in GitHub Desktop.
class User < Ohm::Model
set :requests, :Request
end
class Request < Ohm::Model
attribute :path
attribute :processed
attribute :origin
index :path
index :processed
end
search = Custom::Search.new("string to search")
ids_found = search.ids
# ids_found == ["1", "3", "5"]
user = User[1]
requests = user.requests
# requests.map(&:id) == ["1", "2", "3", "5", "6", "7"]
#here I would need to remove from requests the ones that DOESN'T match the ids in ids_found
#code continues and I need to apply more filters
if processed
requests.find(processed: true)
end
if path
requests.find(path: path)
end
found = requests.sort(:limit => [0, 50])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment