public
Last active

as far as I got trying to use a Metal endpoint to enable render() directly from routes.rb

  • Download Gist
renderdirectly.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
# see: http://yehudakatz.com/2009/12/20/generic-actions-in-rails-3/
class RenderDirectly < ActionController::Metal
include ActionController::Rendering
include AbstractController::Layouts
include AbstractController::AssetPaths
append_view_path Rails.root.join("app", "views", "direct")
append_view_path Rails.root.join("app", "views")
layout "application"
javascripts_dir = Rails.root.join("public", "javascripts")
stylesheets_dir = Rails.root.join("public", "stylesheets")
def index
render *env["generic_views.render_args"]
end
end
 
require 'render_directly'
module GenericActions
module Render
def render(*args, &block)
debugger
app = RenderDirectly.action(:index)
lambda do |env|
env["generic_views.render_args"] = args
app.call(env)
end
end
end
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.