Created
April 23, 2009 18:28
-
-
Save nmerouze/100665 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Rails 3 | |
$:.unshift File.join(File.dirname(__FILE__), 'rack-router/lib') | |
$:.unshift File.join(File.dirname(__FILE__), 'rack-mount/lib') | |
$:.unshift File.join(File.dirname(__FILE__), 'rails/activesupport/lib') | |
$:.unshift File.join(File.dirname(__FILE__), 'rails/actionpack/lib') | |
require 'active_support' | |
require 'action_view' | |
require 'action_view/base' | |
require 'action_controller' | |
require 'action_controller/abstract' | |
require 'action_controller/new_base' | |
module ActionController | |
module Renderer | |
def render(action, options = {}) | |
# TODO: Move this into #render_to_body | |
if action.is_a?(Hash) | |
options, action = action, nil | |
else | |
options.merge! :action => action | |
end | |
_process_options(options) | |
self.response_body = render_to_body(options).to_str | |
end | |
end | |
end | |
module ActionController | |
class MyBase < AbstractBase | |
use AbstractController::Callbacks | |
use AbstractController::Helpers | |
use AbstractController::Logger | |
use ActionController::HideActions | |
use ActionController::UrlFor | |
use ActionController::Renderer # just for clarity -- not required | |
use ActionController::Layouts | |
def erect(name) | |
render :text => name.new.to_s | |
end | |
end | |
end | |
### MyApp | |
$:.unshift File.join(File.dirname(__FILE__), 'app') | |
require 'rack/mount' | |
require 'rack/mount/mappers/rails_draft' | |
MyApp = Rack::Mount::RouteSet.new | |
MyApp.new_draw do |map| | |
resources :posts | |
end | |
require 'models' | |
require 'controllers' | |
require 'views' | |
### Router | |
require 'rack/router' | |
class SimpleRack | |
include Rack::Router::Routable | |
def initialize | |
prepare do |r| | |
r.map "/myapp", :to => Routes | |
end | |
end | |
end | |
use Rack::ContentType, "text/html" | |
run SimpleRack.new |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment