You can specify the layout in your controller. If you want to have a
default layout, it's best to name it "application.rhtml" (or .rxml, or
whichever). Rails will use that as the default for any controller that
doesn't have its own layout. Layouts go in "your_application/app/views/
layouts" by convention, and Rails will look for them there.
So, how does a controller get its own layout? Two ways. The most
common is simply by naming a layout after the controller. For example,
if you have a controller called "FooController", then Rails will look
for a layout called "foo.rhtml" (or .rxml, or whichever) first.
The second way is to explicitly name the layout you want applied to
the views of a controller within the controller itself (this is where
"layout :default" comes in). Say you want FooController to have the
"bar" layout instead:
class FooController < ApplicationController
. . .
Layouts are inherited, so if FoobarController extends FooController,
it will also get the "bar" layout unless you specify otherwise.
Finally, the "layout" declaration can actually take arguments beyond
just strings, so you can conditionally apply layouts and do all sorts
of other craziness if that sort of thing turns you on.