Ruby On Rails Classroom image

Anil  Bist / Professional / Web Technology

 
To post your Question Join Classroom
 
Lesson Topics's No:-  |1 | 2 | 3|Last
Lessons:- Eliminating Duplication with Layouts

  Eliminating Duplication with Layouts

Now that we’ve replaced the variable part of the page titles with ERb, each of our pages looks something like this:

 

In other words, all our pages are identical in structure, including the contents of the title tag, with the sole exception of the material inside the body tag. 

In order to factor out this common structure, Rails comes with a special layout file called application.html.erb, which we renamed in Section 3.3.1 and which we’ll
now restore:

$ mv foobar app/views/layouts/application.html.erb

 

To get the layout to work, we have to replace the default title with the Embedded Ruby from the examples above: 

<title> Ruby on Rails Tutorial Sample App | <%=  yield ( :title ) %> </title>

 

The resulting layout appears in Listing 3.25.

Listing 3.25 The sample application site layout.
app/views/layouts/application.html.erb 

   

 
 
 
image
Anil  Bist

Skills    Ruby On Rails

Qualifications :- High School - SLV, College/University - Graphic Era Deemed Univ University,
Location :-Dehradun,Dehradun,Uttarakhand,India
Description:-

I started my Professional Journey in 2006 with one of the Web Development Company in Bangalore and my 1st framework was "Ruby on Rail" as Web development and delivered around 5+ Projects using this platform. Then came another dimension as JEE/Sturst framework, Gradually I realized that I want to build something on my own and give my passion and energy on creating something different a
Explore

 

  Students (0)