RESTfulルートの処理に使用できるsinatra-rest
gemを確認してください。便宜上、以下に引用します。
[sinatra-restは]SinatraにRESTfulルートを導入するためのテンプレートのセットです。あなたがする唯一のことは、ビューを提供することです。ActiveRecord、DataMapper、またはStoneに基づくモデルに対して自動的にうまく機能します。
たとえば、モデルのクラスの名前がPersonの場合、次の行を追加するだけで済みます。
rest Person
これにより、次のRESTfulルートがアプリケーションに追加されます。(ルートPerson
への複数形に注意してください。)/people/*
Verb Route Controller View
GET /people index /people/index.haml
GET /people/new new /people/new.haml
POST /people create → redirect to show
GET /people/1 show /people/show.haml
GET /people/1/edit edit /people/edit.haml
PUT /people/1 update → redirect to show
DELETE /people/1 destroy → redirect to index