diff options
author | Yehuda Katz and Carl Lerche <wycats@gmail.com> | 2009-04-07 15:54:02 -0700 |
---|---|---|
committer | Yehuda Katz and Carl Lerche <wycats@gmail.com> | 2009-04-07 15:54:02 -0700 |
commit | 95c9718118bc0342ddb320f23b5e0a17fb12b7ad (patch) | |
tree | 131f46b4a147a492def006c6190c58a7e0abd057 /actionpack/lib/action_controller | |
parent | c1aa5b0e14cd4bd27a5d8bd85cf7c36fa5911830 (diff) | |
download | rails-95c9718118bc0342ddb320f23b5e0a17fb12b7ad.tar.gz rails-95c9718118bc0342ddb320f23b5e0a17fb12b7ad.tar.bz2 rails-95c9718118bc0342ddb320f23b5e0a17fb12b7ad.zip |
Layouts work in AbstractController. Add support for the rspec runner for T::U
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r-- | actionpack/lib/action_controller/abstract/layouts.rb | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/actionpack/lib/action_controller/abstract/layouts.rb b/actionpack/lib/action_controller/abstract/layouts.rb index 2680283151..1990941916 100644 --- a/actionpack/lib/action_controller/abstract/layouts.rb +++ b/actionpack/lib/action_controller/abstract/layouts.rb @@ -13,6 +13,10 @@ module AbstractController _write_layout_method end + def _implied_layout_name + name.underscore + end + def _write_layout_method case @_layout when String @@ -24,8 +28,8 @@ module AbstractController else self.class_eval %{ def _layout - if view_paths.find_by_parts?("#{controller_path}", formats, "layouts") - "#{controller_path}" + if view_paths.find_by_parts?("#{_implied_layout_name}", formats, "layouts") + "#{_implied_layout_name}" else super end @@ -45,9 +49,12 @@ module AbstractController def _layout_for_option(name) case name - when String then _layout_for_name(name) - when true then _default_layout(true) - when false then nil + when String then _layout_for_name(name) + when true then _default_layout(true) + when false, nil then nil + else + raise ArgumentError, + "String, true, or false, expected for `layout'; you passed #{name.inspect}" end end @@ -56,7 +63,12 @@ module AbstractController end def _default_layout(require_layout = false) - _layout_for_option(_layout) + begin + _layout_for_option(_layout) + rescue NameError => e + raise NoMethodError, + "You specified #{@_layout.inspect} as the layout, but no such method was found" + end end end end
\ No newline at end of file |