- Automagic support for dynamic API queries.
- Support for custom API call mappings
Created
February 1, 2012 21:33
-
-
Save Spaceghost/1719599 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://<ip:port>/model?modified_after=<value>&page=1&per_page=10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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