diff options
author | Piotr Sarnacki <drogus@gmail.com> | 2012-03-15 16:07:06 -0700 |
---|---|---|
committer | Piotr Sarnacki <drogus@gmail.com> | 2012-03-15 16:07:06 -0700 |
commit | e2b675131204504fc6a60ecc7ecb3279886e6316 (patch) | |
tree | d3c0ad2bb961b25d97bf2a9792c91054a9c8025c /actionpack/lib | |
parent | b9c21aa95b7b3f7763c055a340798b69380fe6d1 (diff) | |
parent | aca693776047f6582109290c4834a3caccfadcc3 (diff) | |
download | rails-e2b675131204504fc6a60ecc7ecb3279886e6316.tar.gz rails-e2b675131204504fc6a60ecc7ecb3279886e6316.tar.bz2 rails-e2b675131204504fc6a60ecc7ecb3279886e6316.zip |
Merge pull request #5454 from luke-gru/luke-dev
allow zero-arity proc for AbstrController::layout
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/abstract_controller/layouts.rb | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/actionpack/lib/abstract_controller/layouts.rb b/actionpack/lib/abstract_controller/layouts.rb index 683a2628a4..3897287af5 100644 --- a/actionpack/lib/abstract_controller/layouts.rb +++ b/actionpack/lib/abstract_controller/layouts.rb @@ -89,7 +89,7 @@ module AbstractController # class TillController < BankController # layout false # - # In these examples, we have three implicit lookup scenrios: + # In these examples, we have three implicit lookup scenarios: # * The BankController uses the "bank" layout. # * The ExchangeController uses the "exchange" layout. # * The CurrencyController inherits the layout from BankController. @@ -128,7 +128,14 @@ module AbstractController # If you want to use an inline method, such as a proc, do something like this: # # class WeblogController < ActionController::Base - # layout proc{ |controller| controller.logged_in? ? "writer_layout" : "reader_layout" } + # layout proc { |controller| controller.logged_in? ? "writer_layout" : "reader_layout" } + # end + # + # If an argument isn't given to the proc, it's evaluated in the context of + # the current controller anyway. + # + # class WeblogController < ActionController::Base + # layout proc { logged_in? ? "writer_layout" : "reader_layout" } # end # # Of course, the most common way of specifying a layout is still just as a plain template name: @@ -299,8 +306,8 @@ module AbstractController end RUBY when Proc - define_method :_layout_from_proc, &_layout - "_layout_from_proc(self)" + define_method :_layout_from_proc, &_layout + _layout.arity == 0 ? "_layout_from_proc" : "_layout_from_proc(self)" when false nil when true |