Skip to content

Instantly share code, notes, and snippets.

@soffes
Forked from wycats/bam.rb
Created February 18, 2010 06:43
Show Gist options
  • Save soffes/307418 to your computer and use it in GitHub Desktop.
Save soffes/307418 to your computer and use it in GitHub Desktop.
class RenderDirectly < ActionController::Base
include ActionController::Rendering
include AbstractController::Layouts
append_view_path Rails.root.join("app", "views").to_s
layout "application"
def index
render *env["generic_views.render_args"]
end
end
module GenericActions
def self.included(base)
base.extend(Render)
end
module Render
def render(*args)
app = RenderDirectly.action(:index)
lambda do |env|
env["generic_views.render_args"] = args
app.call(env)
end
end
end
end
require 'sam_soffes/render_directly'
SamSoffes::Application.routes.draw do |map|
include GenericActions
resources :posts, :only => [:show]
resources :tags, :only => [:index, :show]
match "/", :to => render("pages/home"), :as => "root"
match "/blog", :to => "posts#index", :as => "blog"
match "/music", :to => render("pages/music"), :as => "music"
match "/about", :to => render("pages/about"), :as => "about"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment