Ruby On Rails Classroom image

Anil  Bist / Professional / 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.
spec/requests/static_pages_spec.rb

 

                                        

 

You should verify that these tests fail:

$  bundle  exec  rspec  spec/requests/static  pages  spec.rb
 
 
 
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)