ProblemYou want to create a consistent look across your entire application using a single layout template. SolutionTo apply one layout to every controller view by default, create a layout template named application.rhtml and put it in your application's layout directory (app/views/layouts). For example: app/views/layouts/application.rhtml: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <title>My Weblog</title> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <%= stylesheet_link_tag "weblog" %> <%= javascript_include_tag :defaults %> </head> <body> <div > <%= yield %> </div> </body> </html> DiscussionThe application-wide layout template in the solution will apply to all of your views by default. You can override this behavior per controller (or even per action) by creating additional layout files named after your controllers or by explicitly calling the layout method within your controller class definitions. See Also
|