Ruby On Rails Classroom image

Neha  Jaggi / 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.




You should verify that these tests fail:

$  bundle  exec  rspec  spec/requests/static  pages  spec.rb
Neha  Jaggi

Skills    Ruby On Rails

Qualifications :- High School - , College/University - Graphic Era Hill University, Dehradun, College/University - ,
Location :-Dehradun,Dehradun,UTTARAKHAND,India

Experienced Software Developer with a demonstrated history of working in the Information Technology and services industry. Skilled in Web Technologies (Ruby on Rails, PostgreSQL, php, Laravel and AJAX). 


  Students (0)