public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Search Repo:
Delegate action_name to controller inside views.
lifo (author)
Tue May 06 04:02:24 -0700 2008
commit  e520fd5db7cb839b862c03647effee50f9223d98
tree    91c8775e61b75752a7e4790e2b309921b1faea2f
parent  a53331a161f72b25f6e9c860db43acaf23250f68
...
185
186
187
188
 
189
190
191
...
185
186
187
 
188
189
190
191
0
@@ -185,7 +185,7 @@
0
     attr_internal :request
0
 
0
     delegate :request_forgery_protection_token, :template, :params, :session, :cookies, :response, :headers,
0
- :flash, :logger, :, :to => :controller
0
+ :flash, :logger, :action_name, :to => :controller
0
  
0
     module CompiledTemplates #:nodoc:
0
       # holds compiled template code
...
246
247
248
 
 
 
 
249
250
251
...
544
545
546
 
 
 
 
 
547
548
549
...
246
247
248
249
250
251
252
253
254
255
...
548
549
550
551
552
553
554
555
556
557
558
0
@@ -246,6 +246,10 @@
0
   def accessing_logger_in_template
0
     render :inline => "<%= logger.class %>"
0
   end
0
+
0
+ def accessing_action_name_in_template
0
+ render :inline => "<%= action_name %>"
0
+ end
0
 
0
   def accessing_params_in_template_with_layout
0
     render :layout => nil, :inline => "Hello: <%= params[:name] %>"
0
@@ -544,6 +548,11 @@
0
   def test_access_to_logger_in_view
0
     get :accessing_logger_in_template
0
     assert_equal "Logger", @response.body
0
+ end
0
+
0
+ def test_access_to_action_name_in_view
0
+ get :accessing_action_name_in_template
0
+ assert_equal "accessing_action_name_in_template", @response.body
0
   end
0
 
0
   def test_render_xml

Comments

  • mislav Tue May 06 05:03:22 -0700 2008

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

  • lifo Tue May 06 07:16:34 -0700 2008

    Are there any other ivars I missed ?