Course details

Sinatra Fundamentals

Sinatra Fundamentals

Target Audience
Expected Duration
Lesson Objectives
Course Number
Expertise Level

At the core of Sinatra is the ability to respond to routes. This course includes how to install and use Sinatra with the Thin server. It shows various aspects of route configuration, and covers the use of templates, views, and models, including ActiveRecord and DataMapper. It covers attachments and content streaming, as well as the basics of extensions and helpers, and dynamic modification of block binding. Finally, you'll learn about various aspects of application configuration to support features such as sessions, cookies, caching, and error handling.

Target Audience
Developers familiar with Ruby who want to use Sinatra to create web applications and services


Expected Duration (hours)

Lesson Objectives

Sinatra Fundamentals

  • start the course
  • define Sinatra and describe its characteristics
  • describe how to install Sinatra and the Thin server on UNIX based platforms, and create and run a simple application
  • declare routes using various route verbs in Sinatra
  • configure routes to share the same handler, use parameters, including query string parameters and wildcards
  • describe how the first match is used and how routes can be matched using regular expressions in Sinatra
  • halt, pass, trigger, and redirect requests in Sinatra
  • use filters to modify requests and responses in Sinatra
  • deliver static content from default public folder and other locations without using routing
  • define inline and external templates to work with views in Sinatra
  • use instance variables to pass data to views, and use filters in Sinatra
  • generate and use ActiveRecord models in a Sinatra application
  • generate and use DataMapper models in a Sinatra application
  • configure Sinatra to send attachments to a client
  • configure content streaming including finite streaming in a Sinatra application
  • configure finite streaming in a Sinatra application
  • use the not_found and error blocks to handle errors in Sinatra
  • describe application/class scope, request/instance scope, delegation scope, and associated bindings in Sinatra applications
  • create extensions in Sinatra
  • create and use helper methods in modules in Sinatra
  • use the configure block to apply configuration in Sinatra
  • use set: or enable:key or the settings object to apply settings at class or top level in Sinatra
  • use the headers method in Sinatra to set HTTP headers in response objects to provide information to servers and clients
  • access information via the request object in Sinatra
  • set cache headers, cache control, and content expiration in Sinatra with the headers, cache_control, and expires helpers
  • define and generate ETags (entity tags) including weak ETags
  • enable and destroy sessions using the configure block and session.clear in Sinatra
  • set cookies in Sinatra
  • manage Sinatra dependencies with Bundler
  • develop and configure a basic application in Sinatra
  • Course Number:

    Expertise Level