Skip to content

Instantly share code, notes, and snippets.

@ROFISH
Last active August 29, 2015 14:00
Show Gist options
  • Save ROFISH/11273048 to your computer and use it in GitHub Desktop.
Save ROFISH/11273048 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'bundler/setup'
require 'yaml'
require 'action_dispatch'
require 'action_controller'
require 'action_view'
routes = ActionDispatch::Routing::RouteSet.new
routes.draw do
get '/' => 'mainpage#index'
get '/page/:id' => 'mainpage#show'
end
class MainpageController < ActionController::Metal
include AbstractController::Rendering
include ActionView::Rendering
prepend_view_path('/path/to/templates')
include ActionController::Rendering
include ActionController::ImplicitRender
def index
self.response_body = "<h1>Front Page</h1>"
end
def show
self.status = 404
self.response_body = "<pre>#{env['action_dispatch.request.path_parameters'][:id]}</pre>"
end
end
#use ActionDispatch::ShowExceptions, ActionDispatch::PublicExceptions.new("public/")
use ActionDispatch::DebugExceptions
run routes
#ruby '2.1.0'
source 'https://rubygems.org'
gem 'rack', '~>1.5.2'
gem 'actionpack', '~> 4.1.0.beta1'
gem 'railties', '~> 4.1.0.beta1'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment