Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

ActiveRecord extension for querying data in a restful way

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 rails
Octocat-spinner-32 tasks
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 History.txt
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.rdoc
Octocat-spinner-32 Rakefile
Octocat-spinner-32 init.rb
Octocat-spinner-32 restful_query.gemspec
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

Something went wrong with that request. Please try again.