quirkey / restful_query
- Source
- Commits
- Network (0)
- Issues (0)
- Downloads (2)
- Wiki (1)
- Graphs
-
Tree:
8e1ae8b
commit 8e1ae8bddafb3bb7eec3099d4305593305e4a057
tree 4c076840382c9bc232e0d6a6864986767248c8ca
parent e0215dd4f9a27897ddefdf5cd72b2fd9355b4758
tree 4c076840382c9bc232e0d6a6864986767248c8ca
parent e0215dd4f9a27897ddefdf5cd72b2fd9355b4758
| name | age | message | |
|---|---|---|---|
| |
.gitignore | Sat Mar 21 20:52:34 -0700 2009 | |
| |
History.txt | Sun Aug 09 20:38:31 -0700 2009 | |
| |
LICENSE | Sun Feb 15 20:42:26 -0800 2009 | |
| |
README.rdoc | Tue Nov 03 09:44:16 -0800 2009 | |
| |
Rakefile | Tue Nov 03 08:55:54 -0800 2009 | |
| |
init.rb | Sun Jan 11 19:00:51 -0800 2009 | |
| |
lib/ | Tue Nov 03 09:44:16 -0800 2009 | |
| |
rails/ | Tue Nov 03 08:55:54 -0800 2009 | |
| |
restful_query.gemspec | Tue Nov 03 08:55:54 -0800 2009 | |
| |
tasks/ | Wed Jan 07 14:19:36 -0800 2009 | |
| |
test/ | Tue Nov 03 09:44:16 -0800 2009 |
README.rdoc
restful_query
github.com/quirkey/restful_query
DESCRIPTION:
RestfulQuery provides a RESTful interface for easily and safely querying ActiveRecord data.
USAGE:
Rails/ActiveRecord:
# as a gem, in environment.rb config.gem 'restful_query'
or install the plugin. In your model:
class Post < ActiveRecord::Base
can_query
end
In your controller:
class PostsController < ApplicationController
# ...
def index
@posts = Post.restful_query(params[:query])
end
# ...
end
Now you can query your model via the URL:
/posts?query[name][like]=jon&query[_sort]=created_at-desc
Sequel
Theres also a Sequel extension that works very similar to ActiveRecord::Base.can_query:
require 'sequel/extensions/restful_query'
DB[:posts].restful_query({'name' => {'like' => 'jon'}, '_sort' => 'created_at-desc'})
<Sequel::SQLite::Dataset: "SELECT * FROM `posts` WHERE (name LIKE %jon%) ORDER BY `created_at` DESC">
More!
Please see the project homepage for detailed usage and info:
code.quirkey.com/restful_query
INSTALL:
To install as a gem:
sudo gem install restful_query
To install as a rails plugin
./script/plugin install git://github.com/quirkey/restful_query.git
LICENSE:
Free for use under the terms of the MIT License - see LICENSE for details
