aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorbrainopia <brainopia@evilmartians.com>2015-01-22 00:23:22 +0300
committerbrainopia <brainopia@evilmartians.com>2015-01-22 01:02:13 +0300
commit656628961c009524bd97ec5682b3dab3b850cb8a (patch)
tree2e1d8b910d781f2a0366b623e7bd5fd33fa2c247 /actionpack
parent801e399e42cab610860e307f2dd77c1edb6e1fac (diff)
downloadrails-656628961c009524bd97ec5682b3dab3b850cb8a.tar.gz
rails-656628961c009524bd97ec5682b3dab3b850cb8a.tar.bz2
rails-656628961c009524bd97ec5682b3dab3b850cb8a.zip
Add ActionController::Base.render
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/CHANGELOG.md3
-rw-r--r--actionpack/lib/action_controller/metal/rendering.rb3
-rw-r--r--actionpack/test/controller/renderer_test.rb4
3 files changed, 10 insertions, 0 deletions
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',