A layout defines the surroundings design look of an HTML page. Layout files reside in app/views/layouts: We will define a layout template and then configure the related controller. First, let's create the template. Add a new file called simple_page.rhtml to app/views/layouts. Add the following code to this new simple_page.rhtml file and save the changes: <!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"> <head> <meta http-equiv="Content-Type" content="text/html;. charset=iso-8859-1" /> <meta http-equiv="Content-Language" content="en-us" /> <title>Organics molecules</title> <%= stylesheet_link_tag "styles" %> </head> <body> <div class="trebuch"> <h1>Hydrocarbons</h1> </div> <%= yield -%> <div id="normal" class="ajax2">Organic Related project scientificsentence.net. 2008</div> </div> </body> </html> The related link is toward styles.css style sheet. The yield command allows Rails to use the RHTML file. Now open hydrocarbon_controller.rb and add the following line just below the first line: class HydrocarbonController < ApplicationController layout 'simple_page' ................... Now let's create a the new file "styles.css" and save it in C:\ruby\organics\public\stylesheets directory. This file contains the following style code source: fold & unfold
|