aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/abstract
diff options
context:
space:
mode:
authorYehuda Katz and Carl Lerche <wycats@gmail.com>2009-04-07 17:57:20 -0700
committerYehuda Katz and Carl Lerche <wycats@gmail.com>2009-04-07 17:57:20 -0700
commit3cecbc21e37f772a72917f80c53a7645f81d94c5 (patch)
treefbdb4e9a6934e066ecc14e06b7f76202d54e29b1 /actionpack/lib/action_controller/abstract
parent95c9718118bc0342ddb320f23b5e0a17fb12b7ad (diff)
downloadrails-3cecbc21e37f772a72917f80c53a7645f81d94c5.tar.gz
rails-3cecbc21e37f772a72917f80c53a7645f81d94c5.tar.bz2
rails-3cecbc21e37f772a72917f80c53a7645f81d94c5.zip
Get Base2 layouts to work :)
Diffstat (limited to 'actionpack/lib/action_controller/abstract')
-rw-r--r--actionpack/lib/action_controller/abstract/layouts.rb34
1 files changed, 21 insertions, 13 deletions
diff --git a/actionpack/lib/action_controller/abstract/layouts.rb b/actionpack/lib/action_controller/abstract/layouts.rb
index 1990941916..478b301a26 100644
--- a/actionpack/lib/action_controller/abstract/layouts.rb
+++ b/actionpack/lib/action_controller/abstract/layouts.rb
@@ -17,6 +17,16 @@ module AbstractController
name.underscore
end
+ # Takes the specified layout and creates a _layout method to be called
+ # by _default_layout
+ #
+ # If the specified layout is a:
+ # String:: return the string
+ # Symbol:: call the method specified by the symbol
+ # false:: return nil
+ # none:: If a layout is found in the view paths with the controller's
+ # name, return that string. Otherwise, use the superclass'
+ # layout (which might also be implied)
def _write_layout_method
case @_layout
when String
@@ -46,25 +56,23 @@ module AbstractController
private
def _layout() end # This will be overwritten
-
- def _layout_for_option(name)
- case name
- 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
def _layout_for_name(name)
- view_paths.find_by_parts(name, formats, "layouts")
+ unless [String, FalseClass, NilClass].include?(name.class)
+ raise ArgumentError, "String, false, or nil expected; you passed #{name.inspect}"
+ end
+
+ name && view_paths.find_by_parts(name, formats, "layouts")
end
def _default_layout(require_layout = false)
+ if require_layout && !_layout
+ raise ArgumentError,
+ "There was no default layout for #{self.class} in #{view_paths.inspect}"
+ end
+
begin
- _layout_for_option(_layout)
+ layout = _layout_for_name(_layout)
rescue NameError => e
raise NoMethodError,
"You specified #{@_layout.inspect} as the layout, but no such method was found"