Find the errors in the Library Example.
--------- /app/views/info/staff.html.erb --------
1 <p>Meet the staff:
2 <table>
3 <tr>
4 <td>Head Librarian</td>
5 <td>Frieda Farus</th>
6 <td><%= image_tag 'frieda.jpg", :class => img %>
7 <tr>
8 <td>Reference Librarian</td>
9 <td>Lotus Gergenson</td>
10 <td><% imagetag 'lotus.jpg', :class => 'img' %>
11 </tr>
Ans:
At the end of line 5, replace the /th tag with a /td tag.
Add a /tr tag between lines 6 and 7.
In line 6, replace " with '.
In line 10, replace <% with <%=
In line 10, replace imagetag with image_tag.
Add an /table tag between lines 11 and 12.
--------- /app/views/layouts/application.html.erb --------
12 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
13 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
14 <html>
15 <head>
16 <title><%= @title %></title>
17 <h1><%= @title %></h1>
18 <body>
19 </head>
20 <%= stylesheet-link-tag 'library' %>
21 <table>
22 <tr>
23 <td><%= link_to 'Index Page',
24 { :action => 'index' } %></td>
25 <td><%= link_to 'Staff Listings Page'
26 { :action => 'staff' %></td>
27 <td><%= link_to 'Policies Page',
28 { :action -> 'policies' } %></td>
29 </tr>
30 </table>
31 <hr />
32 </body/>
Ans:
In line 19, the /head tag should be moved between lines 16 and 17.
In line 18, the body tag should be moved between lined 16 and 17,
before the /head tag.
In line 20, stylesheet-link-tag should be replaced by
stylesheet_link_tag and also moved between the head and /head tags.
Add a comma at the end of line 25.
In line 28, change -> to =>
In line 32, change </body/> to </body>
--------- /app/views/controllers/show_info_controller.rb --------
33 class Info Controller > ApplicationController
34 def index
35 title = Index Page
36 def staff
37 title = Staff Listing Page
38 def policies
39 title = Policies Page
40 def page1
41 title = Page 1
42 end
Ans:
In line 33, change > to <
In each method, add single quotes around the string on the
right-hand side of the assignment statement.
Change each instance of title to @title.
Add an end statement at the end of each method, i.e., between
lines 35 and 36, between lines 37 and 38, between 39 and 40, and
between 41 and 42.
--------- /public/stylesheets/styles.css --------
43 body, td { font-family: Trebuchet MS
44 color: navy
45 background-color: silver; }
46 h1 { fontSize; 200%; }
47 img. { width: 1.25; height: 1.5; }
48 td { padding: 0.15in; }
Ans:
Add semicolons at the end of lines 44 and 45.
In line 46, change fontSize to font-size.
In line 46, replace the first semicolon with a colon to separate font-size
from 200%.
In line 47, change img. to .img to make it a class definition.
In line 47, add the units in after 1.25 and 1.5.