Browse files

Delegate action_name to controller inside views.

  • Loading branch information...
1 parent a53331a commit e520fd5db7cb839b862c03647effee50f9223d98 @lifo lifo committed May 6, 2008
Showing with 10 additions and 1 deletion.
  1. +1 −1 actionpack/lib/action_view/base.rb
  2. +9 −0 actionpack/test/controller/new_render_test.rb
View
2 actionpack/lib/action_view/base.rb
@@ -185,7 +185,7 @@ class Base
attr_internal :request
delegate :request_forgery_protection_token, :template, :params, :session, :cookies, :response, :headers,
- :flash, :logger, :to => :controller
+ :flash, :logger, :action_name, :to => :controller
module CompiledTemplates #:nodoc:
# holds compiled template code
View
9 actionpack/test/controller/new_render_test.rb
@@ -246,6 +246,10 @@ def accessing_request_in_template
def accessing_logger_in_template
render :inline => "<%= logger.class %>"
end
+
+ def accessing_action_name_in_template
+ render :inline => "<%= action_name %>"
+ end
def accessing_params_in_template_with_layout
render :layout => nil, :inline => "Hello: <%= params[:name] %>"
@@ -545,6 +549,11 @@ def test_access_to_logger_in_view
get :accessing_logger_in_template
assert_equal "Logger", @response.body
end
+
+ def test_access_to_action_name_in_view
+ get :accessing_action_name_in_template
+ assert_equal "accessing_action_name_in_template", @response.body
+ end
def test_render_xml
get :render_xml_hello

2 comments on commit e520fd5

@mislav
Ruby on Rails member

What about controller_name? Do we still have to write “controller.controller_name”? If so, this is inconsistent

@lifo
Ruby on Rails member

Are there any other ivars I missed ?

Please sign in to comment.