Mark Eschbach

Software Developer && System Analyst

Sinatra

Sinatra is a ruby framework oriented for encapsulating and integrating Rack into describing URI routing with verb-resource pairs. The paris are expessed utilizing Ruby using HTTP verbs defined as functions (ie: get, put, etc), taking the resource path with possible parameters and a block to be executed on match.

Notes

  • ActiveRecord connection pooling.

    When using ActiveRecord with Sinatra you need to notify ActiveRecord when you are done using a database connection. The simplest mechanism to do so is to use the ActiveRecord Rack Middleware: use ActiveRecord::ConnectionAdapters::ConnectionManagement.

  • Running on start

    When running the application manuaully

    Use for service discovery, etc. Effectively overload the run! method on your application class and delegate to super before or after your code.

    Rackup/Thin/Puma/etc use a different entry point, thus making this technique not useful.

    Execute code once Sinatra server is running