1. Computing
Send to a Friend via Email

Sinatra URL Matching


In addition to accessing the parameters through the params hash, you can also access them using block parameters. When using multiple parameters, they're assigned in the same order they appear in the URL.

#!/usr/bin/env ruby
require 'rubygems'
require 'sinatra'

get '/hello/:name' do|name|
  "Hello #{name}"
  # Also available via params hash
  # "Hello #{params[:name]}!"

©2014 About.com. All rights reserved.