Skip to content

Instantly share code, notes, and snippets.

@Spaceghost
Created February 1, 2012 21:33
Show Gist options
  • Save Spaceghost/1719599 to your computer and use it in GitHub Desktop.
Save Spaceghost/1719599 to your computer and use it in GitHub Desktop.
http://<ip:port>/model?modified_after=<value>&page=1&per_page=10

Features

  • Automagic support for dynamic API queries.
  • Support for custom API call mappings
class Offer
extend Searchable
UNSEARCHABLE = [:password, :age, :gender] # Any methods/attributes you don't want to allow to be queried through the API.
self.unsearchable = [:password] if user.admin?
end
class OfferController < ActionController::Base
def index
Model.search(params) do # Pass params in, modify the ones you need, and get a query back based on passed in params!
modified_after: updated_at.gte
end
end
...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment