Permalink
Browse files

Added accessors to logger, params, response, session, and headers fro…

…m 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

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1307 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
dhh committed May 19, 2005
1 parent 68cdcf5 commit aa20834222e829406bf45b133e6413bedf702229
Showing with 14 additions and 0 deletions.
  1. +2 −0 actionpack/CHANGELOG
  2. +2 −0 actionpack/lib/action_view/base.rb
  3. +10 −0 actionpack/test/controller/render_test.rb
View
@@ -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
@@ -122,6 +122,8 @@ class Base
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.
@@ -67,6 +67,10 @@ def hello_in_a_string
@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 @@ def test_nested_rendering
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)

0 comments on commit aa20834

Please sign in to comment.