Skip to content

ruby-grape/grape-with-roar

 
 

Repository files navigation

Grape API with Roar & Mongoid

test

A Grape API that uses Roar and Mongoid with a MongoDB database.

Run

$ bundle install
$ rackup

[2013-06-20 08:57:58] INFO  WEBrick 1.3.1
[2013-06-20 08:57:58] INFO  ruby 1.9.3 (2013-02-06) [x86_64-darwin11.4.2]
[2013-06-20 08:57:58] INFO  WEBrick::HTTPServer#start: pid=247 port=9292

Try with Hyperclient and irb.

require 'hyperclient'

Create some splines.

client = Hyperclient.new('http://localhost:9292/api')

3.times do |i|
  client.splines._post(spline: { name: i.to_s, reticulated: [true, false].sample })
end

Show splines.

client = Hyperclient.new('http://localhost:9292/api')

client.splines.each do |spline|
  puts "spline #{spline.id} #{spline.reticulated ? 'is' : 'is not'} reticulated"
end

Delete splines.

client = Hyperclient.new('http://localhost:9292/api')

client.splines.each(&:_delete)

Hello World

Navigate to localhost:9292/api with a browser. This is a hypermedia API, so all links are clickable.

Hyperclient

This is a good demo to use with Hyperclient. Check out splines_endpoint_with_hyperclient_spec.rb for a complete example that retrieves, creates, updates and deletes splines.

ActiveRecord

This project uses Mongoid and defines a dummy Spline class. Check out the master branch for a complete example that uses ActiveModel and with-activerecord branch for a complete example that uses ActiveRecord and a PostgreSQL database.

Copyright and License

Copyright (c) 2014-2016 Daniel Doubrovkine

MIT License, see LICENSE for details.

About

A demo of using Grape with Roar and some non-trivial HAL presenters.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Contributors 3

  •  
  •  
  •