aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorTim Haines <tmhaines@gmail.com>2008-07-02 04:26:34 +0100
committerPratik Naik <pratiknaik@gmail.com>2008-07-02 04:30:34 +0100
commitf5052dd8a39099e4930faafe9b01e63ced2f6391 (patch)
treeb822185ee19ee7cec9a0e7e8bccc81f4108bc6d5 /actionpack
parentaff2d331720a3143914a0fffd1eba613dc333bfc (diff)
downloadrails-f5052dd8a39099e4930faafe9b01e63ced2f6391.tar.gz
rails-f5052dd8a39099e4930faafe9b01e63ced2f6391.tar.bz2
rails-f5052dd8a39099e4930faafe9b01e63ced2f6391.zip
Make sure render :template works with :locals. [#524 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
Diffstat (limited to 'actionpack')
-rwxr-xr-xactionpack/lib/action_controller/base.rb5
-rw-r--r--actionpack/test/controller/new_render_test.rb9
2 files changed, 13 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index 7cc670289d..a7b2f147e8 100755
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -733,6 +733,9 @@ module ActionController #:nodoc:
# # Renders the template located in [TEMPLATE_ROOT]/weblog/show.r(html|xml) (in Rails, app/views/weblog/show.erb)
# render :template => "weblog/show"
#
+ # # Renders the template with a local variable
+ # render :template => "weblog/show", :locals => {:customer => Customer.new}
+ #
# === Rendering a file
#
# File rendering works just like action rendering except that it takes a filesystem path. By default, the path
@@ -855,7 +858,7 @@ module ActionController #:nodoc:
render_for_file(file, options[:status], options[:use_full_path], options[:locals] || {})
elsif template = options[:template]
- render_for_file(template, options[:status], true)
+ render_for_file(template, options[:status], true, options[:locals] || {})
elsif inline = options[:inline]
add_variables_to_assigns
diff --git a/actionpack/test/controller/new_render_test.rb b/actionpack/test/controller/new_render_test.rb
index deda47f352..eac36a04cb 100644
--- a/actionpack/test/controller/new_render_test.rb
+++ b/actionpack/test/controller/new_render_test.rb
@@ -268,6 +268,10 @@ class NewRenderTestController < ActionController::Base
render :template => "test/hello_world"
end
+ def render_with_explicit_template_with_locals
+ render :template => "test/render_file_with_locals", :locals => { :secret => 'area51' }
+ end
+
def double_render
render :text => "hello"
render :text => "world"
@@ -820,6 +824,11 @@ EOS
assert_equal "world", assigns["hello"]
end
+ def test_template_with_locals
+ get :render_with_explicit_template_with_locals
+ assert_equal "The secret is area51\n", @response.body
+ end
+
def test_update_page
get :update_page
assert_template nil