-
-
Save soffes/307418 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
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 |
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
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