Sha256: 638828e6227db7c3b5d84d84717f8a7dc53fbfed7f4ae954dd29629a3e0bf6ac

Contents?: true

Size: 1.04 KB

Versions: 25

Compression:

Stored size: 1.04 KB

Contents

require 'sinatra/base'
require 'sinatra_more'
require 'haml'

class RoutingDemo < Sinatra::Base
  register SinatraMore::RoutingPlugin

  configure do
    set :root, File.dirname(__FILE__)
  end

  map(:admin, :show).to("/admin/:id/show")
  map :admin do |namespace|
    namespace.map(:update).to("/admin/:id/update/:name")
    namespace.map(:destroy).to("/admin/:id/destroy")
  end
  map(:account).to("/the/accounts/:name/path/:id/end")
  map(:accounts).to("/the/accounts/index/?")
  
  namespace :admin do
    get :show do
      "<p>admin show for id #{params[:id]}</p>"
    end
    
    get :update do
      "<p>updated admin with id #{params[:id]} and name #{params[:name]}</p>"
    end
    
    get :destroy do
      "<p>destroy admin with id #{params[:id]}</p>"
    end
  end
  get :account do
    "<h1>the account url for #{params[:name]} and id #{params[:id]}</h1>"
  end
  
  get :accounts do
    "<h1>the accounts index</h1>"
  end
  
  get '/links' do
    haml :index
  end
  
  get '/failed_route' do
    url_for(:some, :not_real, :id => 5)
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
sinatra_more-0.3.43 test/fixtures/routing_app/app.rb
sinatra_more-0.3.42 test/fixtures/routing_app/app.rb
sinatra_more-0.3.41 test/fixtures/routing_app/app.rb
sinatra_more-0.3.40 test/fixtures/routing_app/app.rb
sinatra_more-0.3.39 test/fixtures/routing_app/app.rb
sinatra_more-0.3.38 test/fixtures/routing_app/app.rb
sinatra_more-0.3.37 test/fixtures/routing_app/app.rb
sinatra_more-0.3.36 test/fixtures/routing_app/app.rb
sinatra_more-0.3.35 test/fixtures/routing_app/app.rb
sinatra_more-0.3.34 test/fixtures/routing_app/app.rb
sinatra_more-0.3.33 test/fixtures/routing_app/app.rb
sinatra_more-0.3.32 test/fixtures/routing_app/app.rb
sinatra_more-0.3.31 test/fixtures/routing_app/app.rb
sinatra_more-0.3.30 test/fixtures/routing_app/app.rb
sinatra_more-0.3.29 test/fixtures/routing_app/app.rb
sinatra_more-0.3.28 test/fixtures/routing_app/app.rb
sinatra_more-0.3.27 test/fixtures/routing_app/app.rb
sinatra_more-0.3.26 test/fixtures/routing_app/app.rb
sinatra_more-0.3.25 test/fixtures/routing_app/app.rb
sinatra_more-0.3.24 test/fixtures/routing_app/app.rb