· 1 min read
Screencast: Rails 3 mit Rack
Download:
Download(12.1 MB, 8:48) Alternativer Download für iPod & Apple TV(12 MB, 8:48)
Resourcen:
- Episode 203: Routing in Rails 3
- Episode 150: Rails Metal
- The Powerful New Rails Router
- The Rails 3 Router: Rack It Up
- Generic Actions in Rails 3
- Routing Rails Guide
- Full episode source code
Quellcode:
[ruby] # routes.rb root :to => “home#index” root :to => HomeController.action(:index) root :to => HomeApp
match “/about” => redirect(“/aboutus”) match “/aboutus” => “info#about”
resources :products match “/p/:id” => redirect(“/products/%{id}”)
match “/processes” => ProcessesApp.action(:index)
# Gemfile gem “sinatra”
# lib/home_app.rb class HomeApp < Sinatra::Base get ”/” do “Hello from Sinatra!” end end
# lib/processes_app.rb class ProcessesApp < ActionController::Metal include ActionController::Rendering append_view_path ”#{Rails.root}/app/views” def index @processes = `ps -axcr -o “pid,pcpu,pmem,time,comm”` render end end [/ruby]
[html]
Processes
<%= @processes %>[/html]