diff options
-rw-r--r-- | actionpack/CHANGELOG | 2 | ||||
-rw-r--r-- | actionpack/lib/action_view/base.rb | 2 | ||||
-rw-r--r-- | actionpack/test/controller/render_test.rb | 10 |
3 files changed, 14 insertions, 0 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index 0c24bf93e0..01f3f700c9 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Added accessors to logger, params, response, session, and headers from the view, so you can write <% logger.info "stuff" %> instead of <% @logger.info "others" %> -- more consistent with the preferred way of accessing these attributes and collections from the controller + * Added support for POST data in form of YAML or XML, which is controller through the X-POST_DATA_MARSHAL header. Example request: X-POST_DATA_MARSHAL: xml diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index b0737f0f0b..998578e35b 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -122,6 +122,8 @@ module ActionView #:nodoc: attr_reader :first_render attr_accessor :base_path, :assigns, :template_extension attr_accessor :controller + + attr_reader :logger, :params, :response, :session, :headers # Turn on to cache the reading of templates from the file system. Doing so means that you have to restart the server # when changing templates, but that rendering will be faster. diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb index fd3e08177a..d3051ef6ad 100644 --- a/actionpack/test/controller/render_test.rb +++ b/actionpack/test/controller/render_test.rb @@ -67,6 +67,10 @@ class TestController < ActionController::Base @customers = [ Customer.new("david"), Customer.new("mary") ] render_text "How's there? #{render_to_string("test/list")}" end + + def accessing_params_in_template + render_template "Hello: <%= params[:name] %>" + end def rescue_action(e) raise end @@ -200,6 +204,12 @@ class RenderTest < Test::Unit::TestCase assert_equal "Living in a nested world", Fun::GamesController.process(@request, @response).body end + def test_accessing_params_in_template + @request.action = "accessing_params_in_template" + @request.query_parameters[:name] = "David" + assert_equal "Hello: David", process_request.body + end + private def process_request TestController.process(@request, @response) |