Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Example with Grape and Mongoid

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 app
Octocat-spinner-32 config
Octocat-spinner-32 .gitignore
Octocat-spinner-32 Gemfile
Octocat-spinner-32 Gemfile.lock
Octocat-spinner-32 README.md
Octocat-spinner-32 config.ru
README.md

Installation

  $ git clone git://github.com/ayosec/grape-mongoid.git
  $ cd grape-mongoid
  $ bundle install --binstubs
  $ bin/thin start

Example with curl

$ curl -s http://localhost:3000/ | json_pp
[]

$ curl -s -d 'failed=1' http://localhost:3000/ | json_pp
{
   "errors" : {
      "name" : [
         "can't be blank"
      ]
   }
}

$ curl -s -d 'name=this+item&foo=bar&this=that' http://localhost:3000/ | json_pp
{
   "thingId" : "4f64a387d1dd1b129d000002"
}

$ curl -s http://localhost:3000/ | json_pp
[
   {
      "created_at" : "2012-03-17T14:45:27+00:00",
      "updated_at" : "2012-03-17T14:45:27+00:00",
      "_id" : "4f64a387d1dd1b129d000002",
      "name" : "this item",
      "foo" : "bar",
      "this" : "that"
   }
]

$ curl -s -d 'name=second+item' http://localhost:3000/ | json_pp
{
   "thingId" : "4f64a394d1dd1b129d000003"
}

$ curl -s http://localhost:3000/ | json_pp
[
   {
      "created_at" : "2012-03-17T14:45:27+00:00",
      "updated_at" : "2012-03-17T14:45:27+00:00",
      "_id" : "4f64a387d1dd1b129d000002",
      "name" : "this item",
      "foo" : "bar",
      "this" : "that"
   },
   {
      "created_at" : "2012-03-17T14:45:40+00:00",
      "updated_at" : "2012-03-17T14:45:40+00:00",
      "_id" : "4f64a394d1dd1b129d000003",
      "name" : "second item"
   }
]
Something went wrong with that request. Please try again.