With rest-sinatra, success is all but guaranteed in writing RESTful Web Services. (Provided that you are using a Sinatra + MongoMapper stack.)
It might not be a bad idea to make sure you are running the latest RubyGems:
sudo gem update --system
I recommend a user-level install (no sudo needed):
gem install djsun-rest-sinatra
Note: in general, beware of sudo gem install <project_name>
-- it gives elevated privileges. Do you trust <project name>
? Better to be safe and use a local install to ~/.gem
.
For a basic example of what this looks like when integrated into a real-world Sinatra app, see sources.rb. For an example of nested resources, see users.rb and users_keys.rb.
This code was extracted from the National Data Catalog, a project of the Sunlight Labs.