Ruby On Rails Classroom image

Pooja  Negi / Student / Web Technology

To post your Question Join Classroom
Lesson Topics's No:-  |1 | 2|Last
Lessons:-Layout Links

  Layout Links 

Now that we’ve finished a site layout with decent styling, it’s time to start filling in the links we’ve stubbed out with ’#’. Of course, we could hard-code links like


<a   href=    "/static pages/about"  >About   </a>


but that isn’t the Rails Way. For one, it would be nice if the URI for the About page were /about rather than /static pages/about; moreover, Rails conventionally uses named
routes, which involves code like 


<%=   link to   "About",    about path   %>


This way the code has a more transparent meaning, and it’s also more flexible since we can change the definition of about_path and have the URI change everywhere about_path is used.

        The full list of our planned links appears in Table 5.1, along with their mapping to URIs and routes. We’ll implement all but the last one by the end of this chapter. (We’ll make the last one in Chapter 8.)

                Before moving on, let’s add a Contact page (left as an exercise in Chapter 3). The test appears as in Listing 5.16, which simply follows the model last seen in Listing 3.18. Note that, as in the application code, in Listing 5.16 we’ve switched to Ruby 1.9– style hashes.  


Table 5.1 Route and URI mapping for site links.




Listing 5.16 Tests for a Contact page.




You should verify that these tests fail:

$  bundle  exec  rspec  spec/requests/static  pages  spec.rb
Pooja   Negi

Skills    Ruby On Rails

Qualifications :- High School - SSN high school, College/University - HNBGU, College/University - SRHU,
Location :-Ranipokhari,Rishikesh,Uttarakhand,India
Description:- Student

  Students (0)