respond_with gem is an extension of Sinatra. It is intended to
make API responses dead simple.
respond_with relies on the serialize gem which is still in development
so you'll need to install that from git.
Add these lines to your application's Gemfile:
gem 'respond_with', :git => 'git://github.com/daneharrigan/respond_with.git' gem 'serialize', :git => 'git://github.com/daneharrigan/serialize.git'
And then execute:
require "sinatra" require "respond_with" # in a sinatra app get "/resources/:id.?:format?" do @resource = Resource.find(params[:id]) respond_with ResourceSerializer.new(@resource) end
Notice we're using a
ResourceSerializer. This is built with the
- Fork it
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Added some feature')
- Push to the branch (
git push origin my-new-feature)
- Create new Pull Request