sinatra.txt

doc/sinatra.txt
Last Update: 2009-01-29 13:40:53 -0800

Sinatra doesn't have a defined folder structure for models, so scaffold_all_models shouldn't be used unless you pass the :only option, which gives a list of models to scaffold.

Sinatra has a defined structure for plugins. To use it, put the plugin in the vendor directory of your application and it should be picked up automatically. Note that if you doing something Sinatra doesn't like (such as using ruby-style to deploy the Sinatra application, or just changing $0), this probably won't work, so you need to require it manually.

To use the plugin if installing the gem:

require 'scaffolding_extensions'

To use the plugin, call one of the scaffold methods inside a Sinatra::Base subclass:

class Scaf < Sinatra::Base
  scaffold Model1
  scaffold_habtm Model1, :things
  scaffold_all_models :only=>[Model1, Model2, Model3]
end

As this is going to add paths directly to where Scaf is mounted, you generally are going to want to mount Scaf at a subpath and build and run you own Rack app:

app = Rack::Builder.app do
  map("/"){run MainApp}
  map("/admin"){run Scaf}
end
Rack::Handler.get('mongrel').run(app, :Host=>'0.0.0.0', :Port=>7976) do |server|
  trap(:INT){server.stop}
end