aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2008-05-06 12:02:24 +0100
committerPratik Naik <pratiknaik@gmail.com>2008-05-06 12:02:24 +0100
commite520fd5db7cb839b862c03647effee50f9223d98 (patch)
tree91c8775e61b75752a7e4790e2b309921b1faea2f /actionpack
parenta53331a161f72b25f6e9c860db43acaf23250f68 (diff)
downloadrails-e520fd5db7cb839b862c03647effee50f9223d98.tar.gz
rails-e520fd5db7cb839b862c03647effee50f9223d98.tar.bz2
rails-e520fd5db7cb839b862c03647effee50f9223d98.zip
Delegate action_name to controller inside views.
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_view/base.rb2
-rw-r--r--actionpack/test/controller/new_render_test.rb9
2 files changed, 10 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb
index a6da81de07..d32c6fbe35 100644
--- a/actionpack/lib/action_view/base.rb
+++ b/actionpack/lib/action_view/base.rb
@@ -185,7 +185,7 @@ module ActionView #:nodoc:
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
diff --git a/actionpack/test/controller/new_render_test.rb b/actionpack/test/controller/new_render_test.rb
index 8e39057f55..6e2c6d90c6 100644
--- a/actionpack/test/controller/new_render_test.rb
+++ b/actionpack/test/controller/new_render_test.rb
@@ -246,6 +246,10 @@ class NewRenderTestController < ActionController::Base
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 @@ class NewRenderTest < Test::Unit::TestCase
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