From 656628961c009524bd97ec5682b3dab3b850cb8a Mon Sep 17 00:00:00 2001 From: brainopia Date: Thu, 22 Jan 2015 00:23:22 +0300 Subject: Add ActionController::Base.render --- actionpack/CHANGELOG.md | 3 +++ actionpack/lib/action_controller/metal/rendering.rb | 3 +++ actionpack/test/controller/renderer_test.rb | 4 ++++ 3 files changed, 10 insertions(+) (limited to 'actionpack') diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md index d8c26fa281..d545c59afc 100644 --- a/actionpack/CHANGELOG.md +++ b/actionpack/CHANGELOG.md @@ -1,6 +1,9 @@ * Add `ActionController::Renderer` to render arbitrary templates outside controller actions. + Its functionality is accessible through class methods `render` and + `renderer` of `ActionController::Base`. + *Ravil Bayramgalin* * Support `:assigns` option when rendering with controllers/mailers. diff --git a/actionpack/lib/action_controller/metal/rendering.rb b/actionpack/lib/action_controller/metal/rendering.rb index 2370c607ed..2d15c39d88 100644 --- a/actionpack/lib/action_controller/metal/rendering.rb +++ b/actionpack/lib/action_controller/metal/rendering.rb @@ -5,6 +5,9 @@ module ActionController RENDER_FORMATS_IN_PRIORITY = [:body, :text, :plain, :html] module ClassMethods + # Documentation at ActionController::Renderer#render + delegate :render, to: :renderer + # Returns a renderer class (inherited from ActionController::Renderer) # for the controller. def renderer diff --git a/actionpack/test/controller/renderer_test.rb b/actionpack/test/controller/renderer_test.rb index 6efc9c8dfd..6d5508323b 100644 --- a/actionpack/test/controller/renderer_test.rb +++ b/actionpack/test/controller/renderer_test.rb @@ -29,6 +29,10 @@ class RendererTest < ActiveSupport::TestCase assert_equal 'Hello world!', content end + test 'rendering with a controller class' do + assert_equal 'Hello world!', ApplicationController.render('test/hello_world') + end + test 'rendering with locals' do renderer = ApplicationController.renderer content = renderer.render template: 'test/render_file_with_locals', -- cgit v1.2.3