Sha256: a3c80bb98fad8ba0a6bebc1be495d0ecc9bcd2aeb5f27f53b8924c9ea01db9c7

Contents?: true

Size: 1.25 KB

Versions: 3

Compression:

Stored size: 1.25 KB

Contents

class RoutingDemo < Sinatra::Base
  register Padrino::Routing

  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

  namespace :autogenerated, :accounts do
    get :index do
      url_for(:autogenerated, :accounts, :index)
    end
  end

  namespace :autogenerated, :accounts do
    get :with_mapping, :map => "/autogenerated/accounts/with/mapping" do
      url_for(:autogenerated, :accounts, :with_mapping)
    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

3 entries across 3 versions & 1 rubygems

Version Path
padrino-routing-0.5.0 test/fixtures/routing_app/app.rb
padrino-routing-0.4.6 test/fixtures/routing_app/app.rb
padrino-routing-0.4.5 test/fixtures/routing_app/app.rb