The HTML code doesn’t validate. I took the time to rewrite a version that validates against XHTML1.0. IMHO even examples should use valid XHTML. Here’s the code (I hope it’s not too long!):
<%
odd_or_even = 0
for product in products
\todd_or_even = 1 - odd_or_even
%>
<tr valign="top" class="ListLine<%= odd_or_even.to_s %>">
\t\t<td>
\t\t\t<img width="60" height="70" src="<%= product.image_url %>" alt="<%= h(product.title) %>" />
\t\t</td>
\t\t<td class="ItemTitle">
\t\t\t<span class="ListTitle"><%= h(product.title) %></span><br />
\t\t\t<%= h(truncate(product.description, 80)) %>
\t\t</td>
\t\t<td align="right">
\t\t\t<%= product.date_available.strftime("%y-%m-%d") %><br />
\t\t\t<strong>$<%= sprintf("%0.02f", product.price) %></strong>
\t\t</td>
\t\t<td class="ListActions">
\t\t\t<%= link_to 'Show', :action=> 'show', :id => product %><br />
\t\t\t<%= link_to 'Edit', :action=> 'edit', :id => product %><br />
\t\t\t<%= link_to 'Destroy', { :action=> 'destroy', :id => product },
\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t:confirm => "Are you sure?" %>
\t\t</td>
\t</tr>
<% end %>
</table>
<p>
<%= link_to "Previous page", { :page =>
product_pages.current.previous } if product_pages.current.previous %>
<%= link_to "Next page", { :page =>
product_pages.current.next } if @product_pages.current.next %>
<%= link_to ‘New product’, :action => ‘new’ %>
And a new CSS class needs to be added:
.ItemTitle {
\twidth: 60%;
}
2005-05-27 | |
379 | | TYPO | In $(id) doc: “Otherwise it returns its qarguement.”
| 2005-05-27 | |
389 | | TYPO | Refers to @request (deprecated) and request inconsistently.
| 2005-05-28 | |
392 | | ERROR | server_settings says “:authentication => One of :plain, :login, or :cram_md5.” but SMTP AUTH is optional; you may omit the authentication options entirely.
| 2005-05-28 | |
439 | | ERROR | Using Apache .htaccess in a production environment is crazy, especially with mod_rewrite: it results in many extra subrequests and should only be used for development convenience. Use a normal Apache config file for production.
| 2005-05-31 | |
443 | | ERROR | “dave> killall -USER1 dispatch,gcgi” should be “dave> killall -USR1 dispatch.fcgi”
Also, USR1 does exist on Windows. You can only TERM.
| 2005-05-28 | |
445 | | SUGGEST | Using a SyslogLogger built on the syslog bindings that come with Ruby solves all of these logging woes; it’s worth a mention: http://rails-analyzer.rubyforge.org/classes/SyslogLogger.html
| 2005-05-28 | |
446 | | TYPO | “RAILS_END=production ./script/runner” should be “RAILS_ENV=production ./script/runner”
| 2005-05-28 | |
2 | | OK | There are several places in the first few pages [not got past there yet] where the word “too” is used at the end of a sentence but after a comma
e.g. “If you need to override the conventions,
Rails makes that easy, too.”
The comma is not needed in this sort of construct I think.
Dave says: I’ll fix punctuation problems during copy edit
| 2005-06-27 | |
14 | | ERROR | first_order = Order.find(1)
puts “Order #{order.customer_id}, amount=#{order.amount}”
Should be
first_order = Order.find(1)
puts “Order #{first_order.id}, amount=#{first_order.amount}”
Doesn’t make sense to identify the order by the Customer Id and also the variable name was off.
| 2005-05-27 | |
369 | | TYPO | “Here are web pages that interact with just like a desktop
application would.”
should be something like
“Here are web pages that you interact with just like a desktop application.”
| 2005-05-27 | |
142 | | SUGGEST | I don’t understand the purpose of the plug for Mike Clark at the top of page 42. Might think of adding some context?
| 2005-05-27 | |
55 | | SUGGEST | How about different faces for ‘Joe’ and ‘David’. Maybe David could be less pissed. ;)
David now looks like David :)
| 2005-05-28 | |
449 | | TYPO | “the alter of performance” should be “the altar of performance”
| 2005-05-28 | |
8 | | SUGGEST | In the first paragraph you write: “Surprisingly, these constraints make it easier to create applications—a lot
easier.”
The first occurence of easier followed by easier again sounds a bit odd. How about the following revision:
“Surprisingly, these contraints make it possible to create applications-a lot easier.”
| 2005-05-27 | |
8 | | TYPO | Section 2.1, paragraph 2, first sentence:
“A model is more that just data;”
should be: “A model is more than just data;”
| 2005-05-27 | |
86 | | TYPO | “instance variables from pervious requests” should read “…previous requests”
| 2005-05-27 | |
9 | | SUGGEST | Last paragraph on page, first sentence. Suggested re-write:
1. As is usual in the software world, the good ideas of the past are frequently ignored by new technologies. OR 2. As is usual in the software world, the good ideas of the past are frequently forgotten during the emergence of a new technology.
| 2005-05-27 | |
14 | | SUGGEST | Unless I miss some major feature/concept here. The examples on this page pertain to class Order NOT Orders. The first example uses class Order correctly but the examples that follow do use a plural form.
| 2005-05-27 | |
15 | | TYPO | Paragraph 4, first sentence: “This code uses the new Order class to fetch the order with an id of 1 and
modify the discount.” should be: “This code uses the new Order class to fetch the order with an id of 1 and
modifies the discount.”
| 2005-05-27 | |
17 | | SUGGEST | Bullet point 4 should be reworded.
| 2005-05-27 | |
17 | | SUGGEST | Last paragraph, second sentence. “Rather than attack it component by component,
let’s get stuck in and write a couple of working applications.” should be possibly written as: “Rather than attack it component by component,
let’s get started by writing a couple of working applications.”
| 2005-05-27 | |
19 | | TYPO | Ruby on Mac OS X Tiger box, first sentence: “It’s good that Apple include Ruby in OS X.” should be: “It’s good that Apple includes Ruby in OS X.”
| 2005-05-27 | |
19 | | TYPO | “doubleclick” should be hyphenated: “double-click” in addition I suggest the following re-wording of the text in parenthesis: “(in the Finder, navigate to Applications > Utilities and double-click on the Terminal icon)”
| 2005-05-27 | |
20 | | SUGGEST | Section 3.4, first paragraph: Suggest to add “can” between the words “you start”. Should read: “If your Rails application uses a database (and most do), there’s one more installation step you may have to perform before you can start developing your code.”
| 2005-05-27 | |
21 | | TYPO | Paragraph 3, second sentence: “Do do this, you’re going to have to install a database driver.” should read: “To do this, you’re going to have to install a database driver.”
| 2005-05-27 | |
22 | | SUGGEST | Just before steps 1 to 3. Instead of “Follow the following steps.” Consider writing: “Follow these steps:”
| 2005-05-27 | |
22 | | TYPO | Step 2, second sentence: “Natigate” should read “Navigate”
| 2005-05-27 | |
25 | | SUGGEST | Section 4.2 second paragraph: “As we discussed Chapter 2,” could use an “in” as in “As we discussed in Chapter 2,”
| 2005-05-27 | |
1 | | OK | I know it’s probably to late now, but instead of the introduction into Ruby it would have been nice to maybe have a appendix section on how-to keep up-to-date with the latest rails. I.e. best practices for using the HEAD Rails release and/or how to manage third-party code (int the vendor folder).
(Dave says: that would be nice, but I think it’s a separate book…)
| 2005-06-27 | |
466 | | SUGGEST | (page bottom) Potential issue when using marshaling: Wouldn’t it be clearer for tutorial purpose to just say what you can’t marshal, i.e. page 535 of Pickax2
This section isn’t really talking about that issue, but yes, it probably should… :)
| 2005-05-28 | |
466 | | SUGGEST | (page bottom, cont’d) & then say that with the (somewhat related) issue of having serialized data sync with the class definitions that were in effect when the data was serialized, that rails’ model declaration takes care of it.
| 2005-05-28 | |
21 | | TYPO | Paragraph 3 Just before the typo already submitted:
“If you’re still reading this, it means you’re wanting to connection…”
should be
“If you’re still reading this, it means you want to connect…”
| 2005-05-27 | |
25 | | TYPO | Under section 4.2 it is said “Rails accepts incoming requests from a browser, decode the request to find a controller, and …”. It should be “decodes” instead of “decode”. Or “Rails accepts incoming request from browser, finds a controller by decoding the request, and …”
| 2005-05-27 | |
28 | | SUGGEST | In figure 4.3 there is a confusing comment “actions” inside method SayController#hello. Perhaps for a beginner that had just been presented at page 10 to the fact “Ultimately, this phase identifies a particular method (called an action in Rails parlance)”, it would be better to add “#…” or “#code goes here”. Or simply nothing as shown in other examples of SayController#hello in the near vicinity.
| 2005-05-27 | |
87 | | TYPO | “But as we continue to develop the application,
it would be nice if all pages had a standarized way of displaying errors” - should be “standardized”.
| 2005-05-27 | |
98 | | TYPO | “We’ve assumed that the list of available payment options an
attribute of the Order model by defining a hash in the model file.” - some words missing from this sentence.
| 2005-05-27 | |
55 | | TYPO | Second paragraph from “David Says” should begin with “Sometimes” instead of “Some times”.
| 2005-05-27 | |
131 | | ERROR | “We saw how to generate the documentation and view the statistics for our application.” We saw how to generate the documentation, but we didn’t view the statistics (it is, however, covered later in the book).
| 2005-05-27 | |
450 | | TYPO | “objectss” - paragraph under the screenshot
| 2005-05-28 | |
56 | | SUGGEST | Beginning first sentence with word like “still”/“however”/“yet” would avoid repeating “because” from previous page.
| 2005-05-27 | |
163 | | OK | The “mock object” shown here is not a real mock object, it’s just a stub. It would be good to see the use of a real mock object, i.e. one which collaborates with the test code.
Mike’s happy with the description of this as a mock object…
| 2005-05-28 | |
166 | | TYPO | “And if a bug pops up (gasp!), we’d write a test to corner it and when the test passed we’d know the bug was corned for life.” - should be “cornered”.
| 2005-05-27 | |
193 | | TYPO | In the David Says, “seperations” -> “separations”.
| 2005-05-27 | |
214 | | TYPO | “Plain old save( ) returns true true if the model object is valid and can be saved.” - One “true” would suffice.
| 2005-05-27 | |
219 | | TYPO | “Looking at this DDL, we can see why it’s hard for Active Record to divine the relationships between tables automatically. The orders and products foreign key references in the line_items table look identical. However, the product_id column is used to associate a line item with exactly one product. The order_id column is used to associate multiple line items with a single order.”
This is not a very clear explanation. The order_id column is used to associate a line item with exactly one order, and in that respect it is like the product_id column. The difference (as I see it) is that the order item is part of the order, whereas it simply refers to the product.
| 2005-05-27 | |
70 | | OK | This doesn’t actually render what was provided.
-
<%= h(product.title) %>
- <%= product.description %>
- <%= sprintf(“$%0.02f”, product.price) %>
It requires a so,
-
<%= h(product.title) %>
- <%= product.description %>
- <%= sprintf(“$%0.02f”, product.price) %>
Yeah - this is a bit ugly. My product descriptions are HTML, and actually are in a number of
’s, so they actually format is shown
| 2005-05-27 | |
237 | | ERROR | “Thus the following code will eliminate 100 queries compared with the previous example”
Numbers hadn’t been given for the previous example!
| 2005-05-27 | |
237 | | TYPO | In Footnote 9: “In fact, it might not work at all! If your database doesn’t support left outer joins, you can use the feature.” - “can” should be “can’t”.
| 2005-05-27 | |
238 | | TYPO | (Bottom of page) “The count is maintained by the object that contains the collection, and is updated correctly is entries are added via that object.” - “is entries” should be “if entries”.
| 2005-05-27 | |
253 | | TYPO | “Final it updates the row.” should be “Finally it updates the row.”
| 2005-05-27 | |
267 | | OK | In figure 15.4, the callbacks don’t nest properly.
I would expect before/after_validation_on_create to nest within before/after_validation, just as before/after_create are nested within before/after_save.
Similarly for update. Is the diagram correct?
Surprisingly, yes
| 2005-05-28 | |
13 | | ERROR | DBI SQL sample code. Shouldn’t the values of id,tax be inverted on update.execute: tax,id?
update= @db.prepare(“update orders set tax=? where id=?”)
| 2005-05-27 | |
270 | | TYPO | “we can save code by aliases the after_find( ) method to after_save( )” - “aliases” should be “aliasing”.
| 2005-05-28 | |
279 | | TYPO | “The position of this row in a lost is acts_as_list is used” - “lost is” should be “list if”.
| 2005-05-28 | |
10 | | SUGGEST | On page 20 of the beta book, in the first real example of how rails
actions work, you use a sample action that adds an item to a shopping
cart with a GET request. Shouldn’t this technically be done with a
POST? The user is already clicking on a button anyway, so it appears
to the untrained eye that there is nothing in the app design that
would preclude using POST instead (unless perhaps you wanted to have
the item added to the cart with ajax or something). And even if you
have a smart reason for doing it this way, wouldn’t it probably be a
good idea at least to have a sidebar explaining to the reader why you
have chosen to break this convention? Otherwise, thanks for writing such a great book!
| 2005-05-29 | |
467 | | SUGGEST | Idioms: this could go combinatorial, how about listing FAQ / Gotcha/idiom lists:
http://www.glue.umd.edu/~billtj/ruby.html
http://www.rubygarden.org/faq/main/all
http://en.wikipedia.org/wiki/Ruby_programming_language#Possible_surprises
Hal’s Ruby Way, starting page 48
http://www.zenspider.com/Languages/Ruby/QuickRef.html
| 2005-05-28 | |
462 | | TYPO | In Appendice A, End of A5:“addp/helpers directory” should be “app/helpers directory”
| 2005-05-28 | |
312 | | TYPO | “It doesn’t need that message to be passed to the next action - it’s for use in the current session only.” - “session” should be “action”.
I made it ‘request’
| 2005-05-28 | |
20 | | ERROR | Step 2, command “sudo make install” requires you to enter your USER password, not your ROOT password.
| 2005-05-27 | |
23 | | SUGGEST | “pop open a shell prompt” might be rephrased. I think of “popping” windows, or a stack…but not “popping” a prompt.
| 2005-05-28 | |
323 | | TYPO | heading: “Time-based Expiry of Pages Caches” - “Pages Caches” should be “Page Caches”, or “Cached Pages”.
| 2005-05-28 | |
60 | | SUGGEST | In footnote, using a dropdown list would not eliminate the need for input validation, unless you’re only trying to protect against typos. “eliminate” could be changed to a less absolute word without diminishing the point.
Wow! Good catch
| 2005-05-27 | |
376 | | OK | Errata on the errata! Page 376 WORDLIST.find(:all) should be WORDLIST.find_all—Dave Thomas" Looks backwards to me; find_all is being deprecated in favor of find(:all), no?
WORDLIST is not a Rails model…
| 2005-05-28 | |
69 | | SUGGEST | Last (full) paragraph: “On line 12 we set the page title” is confusing. Might disambiguate “page banner title” from “HTML <head> page title”.
| 2005-05-27 | |
188 | | TYPO | 3rd paragraph, last phrase. “If formats objects nicely and…” -> “It formats objects nicely and…”
| 2005-05-27 | |
189 | | SUGGEST | Section 13.8, second paragraph, second phrase is ambiguous or missing something. “This is where requests are handled and business logic rules.” Is rules used as a verb or a noun? As a verb the phrase is fine otherwise it’s incomplete.
| 2005-05-27 | |
340 | | TYPO | In figure 17.1 (which is otherwise brilliant) all the step numbers are currently 5. In the description for the third step, “the HTML send to the browser” should be “the HTML sent to the browser”.
| 2005-05-28 | |
341 | | SUGGEST | The description of form_tag refers to the options for url_for. The description of url_for was a long way back - a link would be useful. It is worth pointing out that the method for the form defaults to POST.
| 2005-05-28 | |
291 | | TYPO | “url_for
Create a URL that references this application
url_for(option => value, …])” - Superfluous “]”? Or is something missing?
| 2005-05-28 | |
343 | | TYPO | “Selection lists are those drop-down list boxes with the build in artificial intelligence that guarantees that your choice can only be reached by scrolling past everyone else’s choice.” - “build in” should be “built in”.
| 2005-05-28 | |
344 | | ERROR | At the bottom of p344, there should be an example of using collection_select( ), but we just get a repeat of the previous select() example.
| 2005-05-28 | |
348 | | TYPO | “Note how we override the encoding type to allow dat
to be sent back with the response.” - “dat” should be “data”.
| 2005-05-28 | |
348 | | TYPO | “The picture is uplaoded into an attribute called picture.” - “uplaoded” should be “uploaded”.
| 2005-05-28 | |
357 | | SUGGEST | “Partial Templates” - all the documentation/tutorials I have read for Rails just uses the term “partials”. You use “partial templates” for a while, then slip into “partials” with no explanation. I think it is worth pointing out that Rails uses “partial” to mean “partial template”… or would it be partial page template? (In other contexts we talk of page fragments.) Sorry to be inconclusive - I guess if I were to choose, I would use “partial” from the start and explain that it is a template for a page fragment.
| 2005-05-28 | |
364 | | TYPO | “And, as with sessions, the choice of caching mechanism
can be defered until your application nears (or is in) deployment.” - “defered” should be “deferred”.
| 2005-05-28 | |
364 | | ERROR | “ActionController::Caching::Fragments::MemoryStore.new
Session data is kept in memory. This is not a particularly scalable solution.” - shouldn’t this say “Page fragments are kept in memory…”?
| 2005-05-28 | |
326 | | TYPO | This:
Response
<%= debug(request) %>
Should be:
Response
<%= debug(response) %>
| 2005-05-28 | |
378 | | SUGGEST | File 90: Escape HTML: change ‘ps -a‘ to CGI::escapeHTML(`ps -a`)
| 2005-05-28 | |
338 | | TYPO | “fetches a pagefull of users”
‘pagefull’ should be ‘pageful’ - one L
| 2005-05-28 | |
388 | | TYPO | “Yellow Fade Techniqueq”, should be “Technique”
| 2005-05-28 | |
372 | | SUGGEST | “Your view should not use any Rails layout wrappers (because you’re only updating part of an HTML page).” - at first reading it is not clear on what view is being referred to here. We’ve just seen some of the template containing the use of AJAX, but the view being referred to in the quoted text turns out to be the view of the fragment being replaced in the page.
| 2005-05-28 | |
434 | | TYPO | “An excellent reason to always to through…”
| 2005-05-28 | |
374 | | TYPO | “No change to your action is required—it simply receives it’s data as it normally would.” - “it’s” should be “its”.
| 2005-05-28 | |
377 | | SUGGEST | “Be sure that the action invoked by an observer shouldn’t be overly complex.” - this is a little clumsy. Either “Be sure that the action … isn’t overly complex.”, or “The action … shouldn’t be overly complex.”
| 2005-05-28 | |
387 | | TYPO | “The second line contains the eval(request.responseText) which will allow us to generate Javacsript in the update_many.rhtml template:” - “Javacsript” should be “JavasScript”.
| 2005-05-28 | |
387 | | TYPO | “This makes sure all ’ and ” characters and newlines will get
properly escaped to build a javascript string:" - “javascript” should be “JavaScript”.
| 2005-05-28 | |
387 | | TYPO | “as an JavaScript error will occur” - “an” should be “a”.
| 2005-05-28 | |
388 | | TYPO | “While it’s tempting to use the window.onload event for this, your Effect will then only occur after all page elements (including images) have been loaded with XMLHttpRequest, you can call immediately after all HTML has been received and inserted into the DOM; the images continue to load asynchronously in the background).” - I think there should be a period after “loaded”, and then “With XMLHttpRequest you can make a call…”. (That still doesn’t read too well, given that the focus here is on using effects without Ajax.)
| 2005-05-28 | |
388 | | TYPO | "Placing a
(Dave says: it’s by design—it let’s me add some formatting.)
| 2005-06-30 | |
101 | | ERROR | Problem with code bit, below:
Because :include_blank is true, it now has TWO un-used options, BOTH “select a payment option” AND “”
SUGGESTION :include_blank => false (or leave it out)
——
options = Order::PAYMENT_TYPES.merge(“Select a payment option” => “”)
select(“order”, “pay_type”, options, { :include_blank => true })
(Dave says: good catch…)
| 2005-06-30 | |
91 | | ERROR | In the first implementation of empty_cart in the store controller you say:
def empty_cart
cart.empty!
(etc.)
However, you first need to define cart. With the code the way it is, it doesn’t work. I believe it should be (from page 93):
def empty_cart
cart = find_cart
cart.empty!
(etc…)
| 2005-06-30 | |
118 | | TYPO | The flash counting the items shipped shows up even when the form is not submitted (a normal GET request for the page will trigger it.)
(Dave says: you know, I knew something was wrong there. Thanks for pointing out what)
| 2005-06-30 | |
406 | | TYPO | The example configuration is missing a comma after the line:
:authentication => :login
| 2005-06-30 | |
53 | | OK | I encountered some errors when I’m using Ubuntu Linux. I’m wondering if other people have the same problems. I have everything set up. When I run the command ‘ruby script/generate scaffold Product Admin’ I first got the ‘No such file or directory - /tmp/mysql.sock’. So I located mysqld.sock and put that into my database.yml file. So I rerun the ruby script/generate command again, and I get this error, ‘error Before updating scaffolding from new DB schema, try creating a table for your model (Product)’
Now I checked my databases in mysql and the table Products DO exist. What can be causing this error?
(Dave says: your Ruby installation can’t access your MySQL database)
| 2005-06-30 | |
90 | | OK | The behaviour of displaying the “Invalid product” or “Your cart is currently empty” works fine in Mozilla Firefox, however with IE a blank section is displayed at the top of the form. If the browser is minimized & then maximized the messages are correctly displayed.
Then again perhaps it’s due to the quantities of coffee that I’ve ingested today.
(Dave says: this sounds like a framework bug, as that code uses the autogenerated stuff)
| 2005-06-30 | |
513 | | OK | For the admin.css, I think you mean:
#banner {
background: #ecc;
color: #822;
font: small-caps 40/40px times;
text-align: center;
}
(Dave says: I don’t think so—it cascades to the depot.css file, which sets these)
| 2005-06-30 | |
118 | | OK | I ran into Justin’s issue with the flash, tried his suggestion, and it worked up to a point, except since there is no redirect after the flash, a flash still displays if you do something like click on the ship button or click on Products and back to Shipping.
I fixed it using flash.now[:notice] =’’’
| 2005-06-30 | |
134 | | OK | I expect it’s too late to do anything about this but I thought it was worth mentioning.
I’m not really getting the testing section, I understand most of it ok, but it’s not feeling as useful as it should. I think that the problem might be related to the fiction axiom of “show don’t tell”.
There don’t seem to be any examples of a test that has highlighted an error in the code and led to the code being improved. There is one case where testing has improved the code (the addition of Product#salable?), however, all of the tests that fail seem to be problems with the testing code rather than the application itself.
You’ve told me that testing in this way is important and useful so i’ve tried to pay attention but without some demonstration of its usefulness that I can imagine helping me with one my applications I get that thing where you just read without absorbing anything and start thinking about random stuff like why do samsumas have bubbly skin. The only bits that I really woke up for was the Product#salable? thing which I thought was a pretty good result and the test-driven development section, probably because both of these actually help me write a better application.
This doesn’t seem to be a problem in most of the rest of the book, which is pretty impressive (why do satsumas have bubbly skin?), so maybe if I had a background in testing I would really feel the usefulness of this, i’ll come back to it after reading the pickaxe and see if it makes an impression.
Sorry so long winded.
| 2005-06-30 | |
484 | | TYPO | “instances of \\C{IO}” looks like a markup typo in the
second paragraph of section A.11 Marshaling Objects
| 2005-06-30 | |
72 | | OK | The store.rhtml on line 4 contains:
<%= stylesheet_link_tag “depot”, :media => “all” %>
After copying the stylesheets from the back of the book, I still get an error when I run code that it’s looking for “mediaall.css” and this file is not found. (The code still functions, but I get a console error everytime I load a store page)
If I remove :media => “all” then the code runs as expected without searching for this missing mediaall.css file.
(Dave says: you need 0.13 of Rails)
| 2005-07-01 | |
310 | | OK | :session_key: “…You’ll want to override this, as shown previously”. When? Not in this section. Way back in the sample Store app, maybe? A pointer would be nice.
(Dave says: at the top of the page…)
| 2005-06-30 | |
314 | | TYPO | Top of the page: “everyone’s context is difference” s/b “everyone’s context is different”.
| 2005-06-30 | |
309 | | SUGGEST | “There are two options” [for dealing with session structure changing]. Actually, there are three: Version your session keys, so that session[:order_v2] deal with the old structure, and session[:order_v3] contains the new. Keep the order_v2 code around long enough to deal with any orders in progress. Output stats to see how often it’s called, and when it stops getting called, it’s safe to remove!
| 2005-06-30 | |
126 | | OK | I don’t get why you’re calling the instance method try_to_login, which then calls User.login. Why not call User.login directly from the controller? Just to demonstrate User.new? It might be good to explain that this trickery is in fact not required.
(Dave says: it simplifies passing the parameters in, and it decouples the two)
| 2005-06-30 | |
146 | | OK | The output for the unit tests doesn’t quiet correllate to the ones we’ve defined so far. It should read:
Started
…..
Finished in 0.306023 seconds.
5 tests, 19 assertions, 0 failures, 0 errors
(Dave says: keeping these in step is just to hard. I’ll live with this one)
| 2005-06-30 | |
262 | 252 | SUGGEST | Second paragraph, first sentence:
The phrase “For Example” occurrs twice in the same sentence.
| 2005-06-30 | |
204 | | TYPO | The last sentence of the first graf (line 2) reads: “Note that the Orace adapter is called oci.” I’m guessing s/Orace/Oracle/.
| 2005-06-30 | |
343 | | TYPO | Last sentance of the 4th paragraph: “…which imposes a couple of restrictions: the cannot appear inline…”
Should be “…which imposes a couple of restrictions: theY cannon appear inline…”
| 2005-07-01 | |
475 | | TYPO | 2nd paragraph, first sentance: ends with .. (two periods)
| 2005-07-01 | |
476 | | TYPO | 5th paragraph, second sentance: looks like a space missing between “use” and “string literals:”
| 2005-07-01 | |
478 | | TYPO | Last paragraph on the page: “Instance variables are not directly acessible outside the class”
Should be “accessible”
| 2005-07-01 | |
354 | | TYPO | Date and Time Fields: “There are two sets of data selection widgets” s/b “…date selection widgets”.
| 2005-07-01 | |
359 | | TYPO | error_message_for is improperly given a plural (“error_messages_for”) in the code snippet.
| 2005-07-01 | |
479 | | ERROR | In the “Private and Protected” section, the “class MyClass” declaration does not have its final “end”.
| 2005-07-01 | |
189 | | ERROR | This is in the ‘Time Extensions’ section. I can’t reproduce this, but I’m pretty sure that ‘now.last_year’ and ‘now.next_year’ should return different values!
(Dave says: wow! good spotting)
| 2005-07-01 | |
371 | | TYPO | Misplaced comma: “by keeping each component in its own module it, reduces the chance…” s/b “…own module, it reduces the chance…”
| 2005-07-01 | |
388 | | SUGGEST | “Let’s implement the observer and search actions.” This was a bit confusing, since you don’t actually implement observer in the controller; you let it fall through to the observer.rhtml, which was already shown on the previous page without any indication as to what file it is.
Also, it was a bit confusing that you left off the form_tag surrounds; might be good to point out that observe_field doesn’t need them, but that in a real app you’ll likely need them for the actual “submit” button.
| 2005-07-01 | |
399 | | ERROR | You never show us the partial _item.rhtml, so the example doesn’t work.
| 2005-07-01 | |
342 | | TYPO | footnote 4: “RuyGems”
| 2005-07-01 | |
400 | | SUGGEST | This is the first time content_for() has been used, but it is not explained or called out.
| 2005-07-01 | |
404 | | TYPO | “where the user can reorder element on screen” s/b “…elements on screen”
| 2005-07-01 | |
103 | | OK | Additional comment on page 103. Using the downloaded code for Chapter 12 which incorporates the suggested changes using “redirect_to(:action => ‘checkout’)” I get the following error:
ActionView::ActionViewError in Store#save_order
No rhtml, rxml, or delegate template found for actioncheckout
D:/work/depot12/app/controllers/store_controller.rb:58:in `save_order’
script/server:51
(Dave says: please update to 0.13 Rails)
| 2005-07-01 | |
51 | | TYPO | First paragraph, lines 2-3: “a column called id.>”. The “>” is a typo.
| 2005-07-01 | |
271 | | TYPO | Not really a typo but, hyphenating times-tamp seems a little awkward. I’n no export on hyphenation but I think it should be time-stamp.
(Dave says: thanks!)
| 2005-07-01 | |
380 | | TYPO | Missing space between GMail, and Google.
| 2005-07-01 | |
13 | | OK | Footnote: “SQL is sometimes (incorrectly) referred to as Structured Query Language…” - this strikes me as an over-correction in response to Nicholas Wright’s comment that ANSI only regards SQL as standing for SQL. If you look at http://en.wikipedia.org/wiki/SQL, or read “SQL in a Nutshell”, “Practical PostgreSQL”, or Oracle’s “DBA Certification Exam Guide”, you will find that they all agree with your original footnote: “(1) Structured Query Language, the language used to query and update relational
databases.” The average reader will be happy with this, and would be baffled by your revised version. The only nit they might want to pick is that SQL also covers the definition of relational databases, but really, the original footnote was good enough.
(Dave says: back and forth, back and forth, and where she stops, nobody knows… I’ve compromised)
| 2005-07-02 | |
15 | | OK | “ORM libraries map data base tables to classes” - strictly, object/relational mapping libraries map classes to tables. I know that Rails gets all the detailed information from the DB schema, but you still tell Rails what your model classes are, and can override the default mapping. If you choose to reword this to “ORM libraries map classes to tables”, also change the corresponding sentences on p16: “So an ORM layer maps…”, and “It closely follows the standard ORM model:…”
| 2005-07-01 | |
124 | | OK | When the ‘redirect_to_index’ is refactored up to ApplicationController, it’s put in the ‘private’ section … which I’d think would make it invisible.
(Dave says: but it doesn’t…. private in Ruby means “doesn’t take a receiver”, so it can be called only from within its own object. Controllers are a subclass of ApplicationController, so it all just works)
| 2005-07-01 | |
299 | | TYPO | Interpretsstring requires a space. Halfway down the page at the start of the paragraph.
| 2005-07-01 | |
20 | | SUGGEST | Please move the box about Ruby on Tiger from page 21 to page 20. It would have be nice to read about the problems, and the fix, before running the gem install rails command.
(Dave says" in the final book it’s on a facing page. I can’t really do better without breaking up a lot of flow elsewhere. The joy of layout)
| 2005-07-01 | |
153 | | OK | method“test_index_without_user must include ”follow_redirect" after assert_redirected_to :action=>“login”
(Dave says: chatted with Mike Clark, and he says it’s OK as it. The test seems to pass OK)
| 2005-07-02 | |
130 | | TYPO | In the admin.rhtml code shown here, there is a “” that should not be in the code.
I assume this was to supress errors if people copied the code from the back of the book. At this point however, all the actions should be present and so the comments should not be there.
(Dave says: removed in final version)
| 2005-07-01 | |
398 | | TYPO | cannonical (should be canonical)
| 2005-07-01 | |
219 | | TYPO | After the second sentence in the “Deleting Rows” section there
should be a space between database. and delete().
| 2005-07-02 | |
453 | | TYPO | Calculation doesn
| 2005-07-02 | |
222 | | OK | divine the relationships, should probably be divide.
(Dave says’ ‘divine’ is what I meant—to understand using vaguely supernatural means)
| 2005-07-02 | |
100 | | OK | This example used :symbols instead of strings, my version of the ActionPack seems to prefer the strings, otherwise I couldn’t get the text_area rows and columns to work at all. Other places in the book use strings so it’s not consistent. Its wrong in the index p. 538, 539, 545, wrong on page 100, but appears correct everywhere else in the book. In Beta 2, it was wrong in more places and that was a headscratcher for me.
(Dave says: again, folks, the book documents Rails 0.13. Older versions don’t support all the stuff in the book)
| 2005-07-02 | |
345 | | TYPO | First para: “These create Javascript snippets on the which run”. Should probably be “on the fly”.
| 2005-07-02 | |
61 | | TYPO | In the footnote, last sentence, you have, “… before using in in a …”. The fisrt “in” should be “it”.
| 2005-07-02 | |
72 | | OK | Have the “Add to Cart” links align (they look odd next to $ of different widths). Have the “Show my cart” link use the same appearance (note that it doesn’t show in your figure 7.2 at alll) and use the same capitalization as the “Add to Cart” links. I think it might look good if all these links floated to the right.
(Dave says: there’s a bunch of aesthetic work to be done on the layout, but for now I think I’ll pass on this)
| 2005-07-02 | |
115 | | SUGGEST | Maybe when you introduce admin.css you should move the styles earlier added to scaffold.css into it. That would leave scaffold.css in its original form, and would mean that the stylesheets listed in the Appendix would contain all your styles.
(Dave says: yes, that’s a good idea.)
| 2005-07-02 | |
515 | | SUGGEST | My comment:
/* = Use the Holly Hack on .catalogentry = */
is visually obtrusive and doesn’t explain what the hack does. Suggest:
/* This uses the Holly Hack to work around layout bugs in IE on Windows */
| 2005-07-02 | |
371 | | TYPO | Grammar error perhaps?? - “… that it normal circumstances would …”. I think it would read better as “… that under normal circumstances would …”
(Dave says: it was supposed to be ‘in’)
| 2005-07-02 | |
94 | | SUGGEST | "If you define helper methods in the file app/helpers/application_helper.rb, those methods will be available in all views. As displaying dollar amounts seems to be a fairly universal thing, let
| 2005-07-03 | |
63 | | OK | The code for validating the image URL includes a check for a leading “http:” but your examples on page 56 show just the path without the http:. I usually leave the protocol and domain name off of URL’s I store in a database unless I am refering to a resource from another domain. Also, by not specifying the protocol, the image_url can be used from regular web pages and pages protected with SSL using https: as the protocol. In my code, I have modified the format pattern in validates_format_of to be %r{^.+\\.(gif|jpg|png)$}i
(Dave says: the problem is, this allows for JavaScript insertion. I feel I’m caught between a rock and a hard place on this one. I was originally the way you have it, but I changed it after Johannes pointed out the JavaScript issue. In retrospect, that was probably a silly change, but it isn’t one I can easily back out this late.)
| 2005-07-02 | |
19 | | OK | Under section 3.1 Step 1, there should be two dashes in the command gem —version and not gem -version as is printed. One dash will cause an error. Two dashes returns the Gem version number, in my case 0.8.10
Love the book!
(Dave says: Thanks! There seem to be two dashes, at lease viewing it using Acrobat)
| 2005-07-03 | |
104 | | TYPO | third line from below, "there
| 2005-07-03 | |
170 | | TYPO | First paragraph under “Schedule Continuous Builds”, last sentence is
“..so you might was well put it to work running tests for you.”
“was” should be “as” unless I have really lost touch with the english language…
| 2005-07-03 | |
330 | | TYPO | 7th paragraph: "For example, Rails let
| 2005-07-03 | |
| 105 | OK | At the bottom of the page, adding the stylesheet reference was confusing to me. It took me way too long to figure out which file this goes in. It just feels like it could use a sentence or two rather than just the code snippet.
(Just above the code it says “add to the store layout file” and there’s a file reference in the margin. I’m not belittling the time you took, but in this case I really wanted to focus on moving forward to the checkout portion. As the tutorial moves forward I’m deliberately making things terser as folks get more exsperienced with Rails :)
| 2005-07-04 | |
95 | | TYPO | @page_title was set to “Your Pragmatic Cart” back on p. 91, but this is not reflected in the screen display.
| 2005-07-04 | |
5 | | SUGGEST | I am finding it very difficult to map the File numbers to the correct version of the file for the position in the book.
In the Rails-code download, the files are organized as depot[1-19] and depot_ws, depot_testing, depot_final. The Book doesn’t seem to have any mapping as to which version should be used at that stage in the book. Maybe add a prefix to the file number or change the file directories to be depotChapter> or Depot
(Dave says: oops - I stripped the prefix off for an earlier iteration and forgot to add it back. Thanks)
| 2005-07-04 | |
98 | | SUGGEST | Capitalize ‘order’ in the invocation of the generate script toward the bottom of the page. The script is smart enough to compensate for it, but it looks funny in light of what you’ve said about naming conventions (similar problem with ‘say’ back on p. 28)
| 2005-07-04 | |
101 | | SUGGEST | Using an array of pairs for PAYMENT_TYPES instead of a hash eliminates the unpredictable ordering of the select list (i.e., [[‘Check’, ‘check’], [‘Credit Card’, ‘cc’], [‘Purchase Order’, ‘po’]]), and is the technique shown in the Rails documentation.
You can then include the default/blank option as follows: options = Order::PAYMENT_TYPES.insert(0, [‘Select a payment option’, ’’])
(Dave says: yeah… I put this off and put this off, but I really do need to change it. Note, btw, that the code above modifies the array in the model)
| 2005-07-04 | |
101 | | SUGGEST | For consistency, consider using <%= submit_tag ’ CHECKOUT ’ %> (as shown at the top of the previous page) to generate the form’s submit button.
| 2005-07-04 | |
105 | | TYPO | @page_title was previously set to “Checkout”, but this is not reflected in the screen display.
| 2005-07-04 | |
82 | | OK | Not sure if its just me, but the results I clicked on the Add to Cart link at this point left me with "`/store/add_to_cart/4’ not found.’ instead of what the book shows. The URL was also http://localhost:3000/store/add_to_cart/4. (the last number changes based on which item I selected the add to cart link.)
I did get a similar WEBrick error message, and when I went on to update the application.rb, it all works correctly and I get the correctly displayed http://localhost:3000/store/display_cart
(Dave says: I just tried it and I get the message as shown. Perhaps you’re missing the ‘redirect’ at the end?)
| 2005-07-04 | |
514 | | OK | .olheader {
font: bold large sans-serif;
color: #411;
margin-bottom: 2ex;
}
.olnamebox, .olitembox {
padding-bottom: 3ex;
padding-right: 3em;
border-top: 1px dotted #411;
}
I think you mean to use 3em instead of 3ex.
(Dave says: why? em is horizontal measure, ex is vertical…)
| 2005-07-04 | |
N/A | | TYPO | The comment at the start of each .rhtml file in the source code isn’t being closed correctly. It should be closed with —>, not !—> (this isn’t a problem for Rails, but it does cause problems with syntax highlighting in text editors).
(Dave says: thanks - this is a new way of deliverig code, and that slipped through..)
| 2005-07-04 | |
13 | | ERROR | EXEC SQL uses variable :amount, however the next line (tax = calc_sales_tax(amt)) uses “amt” while referencing the seemingly same variable. Also, the next example uses amt. These should probably be consistent.
| 2005-07-04 | |
12 | | SUGGEST | You present two approaches to database access, database-centric programming and object/relational mapping on general level. However, you suddenly start talking about Rails in the “Object/Relational Mapping” paragraph: “In addition, the Rails classes that wrap our database tables provide…”. The problem here is that you’ve really not yet said (at least in this chapter) that ORM is the approach Rails/AR is using. I think it would be less confusing for the reader if you’d have a short mention like: “…it invented a three-letter acronym: ORM, Object/Relational Mapping. This is the approach Rails is taking.”
| 2005-07-04 | |
45 | | OK | “I always like to have an idea…”. Who likes it? It’d be nice to know who wrote which chapter when they are that personal.
(Dave says: I’ll leave folks to work that out for themselves…)
| 2005-07-04 | |
196 | | TYPO | David Says: “The notion of a database administrator (DBA) as a separate role from programmer has lead some developers to see strict boundaries between code and schema.” - “has lead” should be “has led”
| 2005-07-04 | |
449 | | TYPO | line 1: something such this -> something like this
(Dave says: should be ‘such as’)
| 2005-07-04 | |
6 | | OK | The note on page 5 on “Rails Versions” doesn’t make clear that 0.13 is not readily available. I had assumed I had the correct version since I followed the directions later on on installing rails.
So now that I know I have the wrong version, how do I install 0.13 release of Rails? I’ve searched the web, thought I had it from the tip on download.rubyonrails.com, it says to get the Beta version use: gem install rails —source http://gems.rubyonrails.com
But I still get 0.12.1 version.
Do I have to follow the instructions to use the Subversion repository as described in http://wiki.rubyonrails.com/rails/show/EdgeRails ?
That looks a bit disconcerting, more in that it will put me out of sync with just using gems and a big danger of screwing things up.
Or is there another way to get 0.13 that I’m missing?
(Dave says: 0.13 was supposed to have been released today (July 4th). I’m trying to see why it hasn’t been)
| 2005-07-05 | |
291 | | TYPO | Last paragraph before Controller Naming section ends with “…pass in two-digit numbers. The”; either a sentence is missing here, or “The” should be excised.
| 2005-07-05 | |
295 | | TYPO | First paragraph: “we could us” => “we could use”
| 2005-07-05 | |
297 | | TYPO | Under “reponse”: processin => processing
| 2005-07-05 | |
511 | 526 | TYPO | The closing paren on the sprintf call in exception_notification somehow mutated into a ‘]’
| 2005-07-07 | |
32 | 34 | TYPO | On page 31 the HTML code uses
tags but on Figure 4.4 (page 32) it changes to
all of a sudden. Furthermore, on page 35 you use
in the example on top and
on bottom. Just letting you know!
| 2005-07-07 | |
359 | 366 | TYPO | A little more than halfway down the page, the code example:
<%= error_message_for(:product) %>
is used: the correct name of the method is “error_messages_for” (“s” in “messages”).
| 2005-07-07 | |
169 | 176 | TYPO | class OrderTest < Test::Unit::TestCase needs to be prefixed by the lines
require File.dirname(FILE) + ‘/../test_helper’
require ‘store_controller’
found on page 507
| 2005-07-07 | |
169 | | OK | When running the performance test on p. 169 the test itself fails with these lines:
1) Failure:
test_save_bulk_orders(OrderTest) [test/unit/performance/order_test.rb:28]:
Actually took 6.00997114181519 seconds.
is not true.
1 tests, 605 assertions, 1 failures, 0 errors
Is this test supposed to fail? If not, why is it, given that I’ve copied straight from the book?
(Dave says: your machine is simply slower than Mikes. You’ll need to run in (say) 8 seconds, not 3)
| 2005-07-07 | |
107 | 113 | TYPO | "While we
| 2005-07-07 | |
109 | 115 | TYPO | "we
| 2005-07-07 | |
167 | 174 | TYPO | "Although it
| 2005-07-07 | |
175 | 183 | TYPO | In figure 13.2, the name of the “layouts” folder is partly hidden by the folder graphic.
| 2005-07-07 | |
175 | | TYPO | “The main code for your application lives below the app directory, as shown in Figure 13.2.” - the period at the end of this sentence has dropped onto the next line.
| 2005-07-07 | |
193 | | TYPO | [“id”, “name”, “email”, “address”, “pay_type”, “shipped_at”]
#<ActiveRecord::ConnectionAdapters::Column:0x10e4a50
default=nil,
limit=nil,
name="shipped_at",
type=:datetime>
- this console output would look better all in blue.
| 2005-07-07 | |
10 | 12 | TYPO | Should be “This triumvirate — the model, view and controller — forms…” (rather than ‘form’)
| 2005-07-07 | |
12 | 14 | TYPO | Para 3: your applications becomes => you application becomes
| 2005-07-07 | |
50 | 54 | TYPO | In the session that follows, We
| 2005-07-07 | |
73 | 77 | TYPO | a .rhtml file => an .rhtml file
| 2005-07-07 | |
108 | | TYPO | Added an orders table (with corresponding model) and linked them to
the line items we
| 2005-07-07 | |
226 | 235 | TYPO | :class_name is repeated twice in the list:
The options :class_name, :foreign_key, :condi-tions, :class_name, :order, and :dependent work the same way as they do with has_one.
| 2005-07-07 | |
1 | | SUGGEST | The “Report erratum” link on each page of the PDF is a good addition, but may lead to a lot of duplicate reports. If the link led to a web page that showed existing errata for the relevant book page as well as letting the reader add a new one, that would be perfect. (Oh, and the current message on the “Add Erratum” page about needing beta gems should be updated to refer to version 0.13)
(Dave says: what a good idea. Done)
| 2005-07-08 | |
260 | 270 | TYPO | (top of page) “doppleganger” should be “doppelganger”
| 2005-07-07 | |
64 | | OK | In the erb listing at the top, the following line appears:
|
<h product.send(column.name)>
|
Is <%=h a typo?
<Dave says: h() is a method that escapes HTML>
2005-07-07 | |
287 | 298 | TYPO | “An incoming URL ofhttp://my.app/admin/book/edit/123” should be “An incoming URL of http://my.app/admin/book/edit/123”.
| 2005-07-07 | |
294 | 305 | TYPO | “just one call to a render( ) or send_( )xxx method” - “send_( )xxx” should be “send_xxx( )”.
| 2005-07-07 | |
302 | 313 | TYPO | link in margin to p478 has no topic (unlike all others AFAIK)
(Dave says: should say ‘marshal’)
| 2005-07-07 | |
310 | 321 | SUGGEST | “You can delete all sessions that have not been modified in (for example) the last hour by having your sweeper task issue SQL such as
delete from sessions
where now() - updated_at > 3600;”
- this may have problems when the clocks go forward for Daylight Savings Time. Need the current and recorded time to be UTC.
(Dave says: excellent point!)
| 2005-07-07 | |
318 | | TYPO | “:add_flash =>hash
Merges the given hash of key/value pairs into the session hash.” - “the session hash” should be “the flash”, or (as the RDoc has it) “the session’s flash”.
| 2005-07-07 | |
410 | 422 | TYPO | “One line aliases this array to the more managable name @emails.” - “managable” should be “manageable”.
| 2005-07-07 | |
207 | 216 | TYPO | Second line from the bottom: ``but the as the’’ (???)
| 2005-07-10 | |
450 | 463 | TYPO | “Webrick:
./script/server —environment=production”
The font used here doesn’t show clearly that there are two ‘-’ characters before “environment”.
The fixed width font used for the following examples should do the job. Also, “Webrick” should be “WEBrick”.
| 2005-07-11 | |
456 | 470 | SUGGEST | “Scaling: The Share-Nothing Architecture” - you use “share-nothing” in the title and the text, but “shared-nothing” in the caption to Figure 22.3.
Both are valid; “shared-nothing” is more usual.
| 2005-07-11 | |
76 | 81 | TYPO | 6th line down: “We can achieve that by creating an helper method…”
Should be “a helper method”.
| 2005-07-10 | |
154 | 161 | TYPO | mercilessly hack -> hacks
| 2005-07-10 | |
171 | 178 | TYPO | Bottom of page: “your Rails application with thank you for it” should be “your Rails application will thank you for it.”
| 2005-07-10 | |
132 | 139 | TYPO | Second sentence, change ‘behaves’ to ‘behaved’
| 2005-07-10 | |
143 | 150 | ERROR | Page 144, first paragraph, “The result in this case is a formatted time 24 hours in the future from the time the test was run”. This isn’t strictly true unless you change the dynamic test fixture on page 143 to
date_available: <%= 1.day.from_now.strftime("%Y%m%d %H:%M:S")>.
| 2005-07-10 | |
332 | | OK | “..links starting :javascript are removed.” I think you meant “links starting with :javascript are removed.”
(Dave says: I’m fairly happy with the existing wording here. Perhaps it’s a UK vs. US English thing…)
| 2005-07-10 | |
126 | | DEFER | The sentence that begins “If you are following along, delete your session file…” refers ,I believe, to a technique discussed in footnote 5 on page 84. The footnote does not use the term “session file”; it calls it a “cookie file”. The technique is much better specified for Unix than it is for Windows. This technique should be discussed in more detail, either here or on page 84.
| | |
264 | 274 | ERROR | (1) Inconsistent identifiers in:
class User < ActiveRecord::Base
before_destroy :dont_delete_dave
def dont_destroy_dave
…
end
end
(2) No margin link to this code
| 2005-07-11 | |
235 | 244 | TYPO | In the last code example of the Preloading Child Rows section, “comment” should be plural:
for post in Post.find(:all, :conditions => “posts.title like ‘ruby’”,
:include => [:author, :comment])
| 2005-07-11 | |
279 | 290 | TYPO | Last sentence in second paragraph from the bottom: ``details ofthe product’’ needs a space.
| 2005-07-11 | |
62 | | OK | Not mission crritical at all: the last line of the page, the erroror message. “Must be a URL for a GIF, JPG, or PNG image” - when listing a group of items, there is no comma between the last two. Should read:
“Must be a URL for a GIF, JPG or PNG image”
(Dave says: we use Chicago rules (5.57))
| 2005-07-10 | |
479 | 493 | TYPO | The first URL in the A.13 Ruby Idioms sections should be:
http://www.glue.umd.edu/~billtj/ruby.html
rather than
http://www.glue.umd.edu/\\protect ~billtj/ruby.html
| 2005-07-11 | |
215 | 224 | TYPO | In the following snippet, a variable named count2 is refered to as counter2
count1 = Counter.find(:first)
count2 = Counter.find(:first)
count1.count += 3
count1.save
count2.count += 4
count2.save
When we run this, we see an exception. Rails aborted the update of
counter2 because the values it held were stale.
| 2005-07-11 | |
96 | 102 | TYPO | the commandline
depot> mysql depot_development <create.sql
should be
depot> mysql depot_development <db/create.sql
| 2005-07-10 | |
451 | 464 | TYPO | "Although this method can be overwritten on a per-controller basis, normally you
| 2005-07-11 | |
154 | 161 | TYPO | In the footnote, “an document object model” should be “a document object model”.
| 2005-07-10 | |
152 | | OK | The login helper-method from page 152 does only work for LoginController tests.
This is because the post method always calls the login action without specifying the controller, so when you use it in an AdminController test it tries to call AdminController#login, which doesn’t exist.
(Dave says: yes, that’s true. However, it does work as advertised in the book. This is a limitation in the UT process() method, which doesn’t allow the controller to be overridden)
| 2005-07-12 | |
344 | 356 | TYPO | A small error: “For example, the following template lets a user alter one of (should be or) more image URLs associated with a list of products.”
| 2005-07-11 | |
65 | | OK | I’m uncertain if this is just an issue on my system, but when printing this and other pages that contains italic text, such as:
link_to(“Next page”, { :page => @product_pages.current.next })
the italic text does not print.
I am using OS X.4.1 and Preview to view and print with. The italic text shows up, but does not print on my (SAMSUNG) laser printer.
Secondly, although the Red borders top/bottom looks nice, they are not exactly printer friendly, and after about 10-20 pages, they fade away, so that the text within them does not show.
Other than these two minor points of ‘irritation’, I must say I truly enjoy the writing style and layout in/of the book. Thank you !
(Dave says: I’ve had one similar report, also from Preview on Tiger. As it works OK inAcrobat on Tiger, and as it appears OK on the screen, I’m tempted to say that this is probably a Preview issue, and I’ll mark this as “not a problem” for now. However, if any additional information comes to light,. please let me know)
| 2005-07-11 | |
295 | | TYPO | In the render(:inline) example:
Unknown action: #{name}
Shouldn’t that be <%= #{name} %>
(Dave says: not really- at this point it’s just a straight string substitution)
| 2005-07-11 | |
52 | 56 | TYPO | You have a chart here that shows the original database.yml file and the new modified one with all the modifications in bold. You fail to make the production/username bold despite that fact that it is modified.
| 2005-07-11 | |
| 51 | OK | I found a few weird things here I wasn’t sure about. Your first mention of the new ‘id’ column has it written as “id.>” Next, you change ‘id’ from a different font (as you have it previous) into italics at the end of the paragraph. Third and final, the last sentence on pg 51 sounded very strange to me and I had trouble understanding it. A rule that you mistype a password? Hope this helps.
(Dave says: The font should change based on the usage: if I say a column named id, I use the code font. If I’m talking about ids, I use regular font. (Or, at least, I should do…)
| 2005-07-11 | |
508 | | OK | The font, text-align, padding-top, padding-bottom and border-bottom lines are missing from this version of admin.css. This causes the banner text to be normal size and left justified. Beta 2 used the .titlepagename tag in admin.css which does not work.
(Dave says: aren’t the attributes inherited from depot.css?)
| 2005-07-11 | |
90 | | OK | The box at the top is labeled “David Says” but seems to be a “Joe Asks” section.
(Dave says: nope- it’s DHH explaining his philosophy)
| 2005-07-12 | |
373 | | OK | The second bullet point should read “The fact that we can’t…”
(Dave says: it’s probably a UK vs. US Engligh thing, but I’m happy to have it without the ‘that’ :)
| 2005-07-12 | |
81 | 86 | ERROR | With Rails 0.13.1, the stub cart is displayed correctly without modifying application.rb
(Dave says: yes—this was a change that was introduced in 0.13.1—0.13.0 worked the way the book describes. I have a problem here, because the book delcares itself to document 0.13. For now I’ll leave it as it is, and change this in a second printing)
| 2005-07-12 | |
512 | 527 | ERROR | the code shown in exception_notification.rhtml fails with an error about PP being undefined (using rails 0.13.1 gems, ruby 1.8.2 from freebsd ports)
adding <% require ‘pp’ %> to the top of the file fixes this error
| 2005-07-12 | |
451 | | OK | As described in http://dev.rubyonrails.com/ticket/1659, the rescue_action_in_public method outlined here fails with a NameError
(Dave says: this would seem to be a problem with Rails, rather than with the book)
| 2005-07-12 | |
71 | 75 | TYPO | re: <% for product in @products -%>
I can’t find any explanation for what the dash/minus means in front of the [ -%> ] tag. I think that you should have some explanation in there somewhere. It’s not even easily found when googling, but thanks to IRC i found the answer.
(Dave says: or you could have looked in the index under <…>. It’s also described (I admit, somewhat belatedly) on page 82. I’ve removed the -%> from page 71 :)
| 2005-07-12 | |
161 | | OK | Bottom of the page: “mocking objects” means making fun of objects, not creating mock objects.
(Dave says: true, but… :)
| 2005-07-13 | |
162 | | OK | “By using mocks” — mock is an adjective, not a noun.
(Dave says: it’s colloquial usage to say things such as “I love the reds and yellows in that picture.” I think that “object(s)” is/are implicit in this sentence)
| 2005-07-13 | |
360 | | OK | The :object option seems to have been removed in rails 0.13.1.
(Dave says" it’s removed from render() in controllers, but not in the view)
| 2005-07-13 | |
36 | | OK | In earlier portions of the book, you how data is routed using a URL similar to:
http://www.pragprog.com/online/demo/say/hello - stating that the URL, up to the demo portion, identifies the application. This is a bit confusing when you get to around page 36 or so. When you start Webrick(sp?) using “ruby script\\server” from within the actual application directory, the Webrick server is specific to that one application. With numerous applications, they may be under extended URLs using the application name, but for testing purposes, the URL will be specific to that single application. I hope that makes sense. The confusing portion would be someone like myself who is a RubNewb (you can use that if someone hasn’t already coined it) attempts to access their demo app at http://localhost:3000/demo/say/hello rather than http://localhost:3000/say/hello.
(Dave says: yes, this is not ideal, but I didn’t want to over-simplify at the start. However, once you get to webrick, it’s one app per server, and the routes (at least by default) are simpler. I’d like to leave it as it is, and perhaps leave this entry in the errata list to see what other folks think)
| 2005-07-13 | |
244 | | OK | In the parent -> child acts_as_list example, it uses acts_as_list :scope => :parent_id, where it should be just :parent, as when a symbol is used rails automatically tacks on the _id.
(Dave says: either works, although the => parent form is probably cleaner)
| 2005-07-13 | |
413 | 425 | TYPO | Original text:
"So, we
| 2005-08-10 | |
486 | 501 | TYPO | http://www.pragmaticprogrammer.com/titles/railscode.html
Should be:
http://www.pragmaticprogrammer.com/titles/rails/code.html
| 2005-08-10 | |
376 | 388 | TYPO | “These library” => “These libraries”
| 2005-08-10 | |
10 | 12 | TYPO | Within the description of a controller, “ouside” should read “outside”. Cheers.
| 2005-08-10 | |
52 | 56 | TYPO | “Figure 6.1: Configure thedatabase.ymlFile” (missing spaces)
| 2005-08-10 | |
486 | | SUGGEST | I downloaded the source code for the book. The .zip file expands to 13M+. Of this, nearly 10M are the files development.log, production.log and test.log for the various projects. Is there a reason why these were included or should they be stripped before creating the code archives?
(Dave says: good point!)
| 2005-07-19 | |
53 | 57 | TYPO | footnote 3: “going back to on page 21”
“on” is not correct
| 2005-08-10 | |
309 | 320 | TYPO | On the third paragraph, second sentence, it says “You hardware…” when it should really be “Your hardware…”.
| 2005-08-10 | |
62 | | DEFER | The suggested image url is relative /images/sk_auto_small.jpg but the validation requires a full url starting with http.
(Dave says: I’m going to tidy all that up in the next edition: it was a change made at the suggestion of a reviewer, but in retrospect I regret it)
| | |
71 | 75 | TYPO | 3/4 down page
"We
| 2005-08-10 | |
81 | | OK | “Although not in Rails 0.13.1 or later, where the steps on this page
are no longer necessary.”
As a result of this sentence, and since I didn’t get a WEBrick error, I skipped the modifications on page 81. However, when I made the modification to the cart to comine identical line items and increase the quantity, this didn’t happen. I think we still need to update ApplicationController regardless of the version but the instructions make it seem like you don’t need to do so if you have 0.13.1. This confusion is possibly due to a change in pagination?
(Dave says: the Rails-core folks tell me it shouldn’t be necessary: if it is, you’ve likely found a bug in Rails)
| 2005-08-07 | |
441 | 444 | SUGGEST | The book says that Debian leaves the echo service enabled. As of the Sarge release, they’ve now fixed this.
| 2005-08-10 | |
279 | 290 | TYPO | The second sentence of the last paragraph says “… so that article dates could be enoded in the request URLs.” This should be “encoded”.
| 2005-08-10 | |
287 | 298 | TYPO | The last line of the page (before the code) reads: "To illustrate this, let
| 2005-08-10 | |
175 | 183 | TYPO | In figure 13.2, all of the folder names are ‘layouts’. ‘app’, ‘models’, ‘helpers’, ‘controllers’ - all of them are mis-named ‘layouts’. It is very confusing - I can only tell because I know what the directory structure is. It was fine in Candidate 1 - it looks like you removed the file icons too, so the graphic has definately changed.
| 2005-08-10 | |
91 | 96 | TYPO | First non-code paragraph (“Over in the cart, …”) has ‘exlamation’ that should read ‘exclamation’. Another easy one for you.
| 2005-08-10 | |
516 | 531 | SUGGEST | shouldn’t bibliography list 2nd edition of pickax?
(Dave says: good catch)
| 2005-08-10 | |
91 | 96 | SUGGEST | on page 91 the section of code added to store_controller.rb is
def empty_cart
find_cart.empty!
flash[:notice] = ‘Your cart is now empty’
redirect_to(:action => ‘index’)
end
and on page 92 when the extracting the flash code to common method the code from store_controller.rb has this
def empty_cart
cart = find_cart
cart.empty!
redirect_to_index(‘Your cart is now empty’)
end
it goes from just one line of code “find_cart.empty!” to two lines of code
cart = find_cart
cart.empty!
Everyting worked fine, either way, just might be confusing for some.
| 2005-08-10 | |
92 | | OK | The code under private reads:
private
def redirect_to_index(msg = nil)
flash[:notice] = msg if msg
redirect_to(:action => ‘index’)
end
The find_cart method is not shown. It should be:
private
def find_cart
session[:cart] ||= Cart.new
end
def redirect_to_index(msg = nil)
flash[:notice] = msg if msg
redirect_to(:action => ‘index’)
end
(Dave says: it’s shown previously. HEre’s I’m just showing the methods that were changed by the refactoring)
| 2005-07-27 | |
221 | 230 | ERROR | In the code example:
invoice = Invoice.new
# fill in the invoice
unless invoice.save!
an_order.invoice = invoice
the “unless” statement should be changed to an “if”. If I understand correctly, you want to avoid doing the assignment if the invoice was not saved. Also, there needs to be an “end” statement at the end.
(Dave says: actually, it s the ‘unless’ that’s wrong. It was left in from a code that existed before save! was invented)
| 2005-08-10 | |
222 | 231 | ERROR | Under ‘belongs_to’, is says that the foreign key is named for the association. While that would make more sense, Rails actually uses the name of the class.
| 2005-08-10 | |
37 | 39 | TYPO | Original text: “4. Rails looks for a template to display the result. It searchs the”
I guess it should’ve been “It searches the” instead of “It searchs the”
| 2005-08-10 | |
38 | 40 | OK | Figure 4.6 appears to be placed to early in the page. It shows a browser render of output of which the code had not been finished yet. Perhaps it should be placed after “You should see something like Figure 4.6.”
(Dave says: this is purely a personal preference: I like figures to be on the same page as the reference to them where possible)
| 2005-08-07 | |
38 | | OK | original text: “Fire up our trusty browser again, but this time point to our new view using the URL http://localhost:3000/say/goodbye. You should see something like Figure 4.6 .”
The full stop at the end of the second sentence is preceded by a space. (“[…] Figure 4.6 .”)
| 2005-08-08 | |
394 | 406 | TYPO | Second paragraph from the bottom (starting “That’s going to require two JavaScript functions”). Second sentence reads:
We
| 2005-08-10 | |
120 | | OK | Page 120: app/view/login/add_user.rhtml
The Field Helpers Attribute should read “hashed_password” instead of “password”
<% @page_title = “Add a User” -%>
.
.
|
Password:
|
<%= password_field(“user”, “password”) %>
|
(Dave says: no - the form captures the plain-text password)
2005-07-27 | |
163 | | OK | Trivial nit: although “flush out” [an idea] is heard more and more often, “flesh out” is probably the desired idiom.
(Flesh out is to complete from a skeleton, flush out is to expose (as it flushing game out of bracken)
| 2005-07-27 | |
352 | | DEFER | It would be nice to see a discussion of file uploading that doesn’t insert the file into the database in a future version of the book.
| | |
53 | | OK | Get the following problem when running:
$ ruby script/generate scaffold Product Admin
…
…
…
force app/views/admin/edit.rhtml
Bad handshake
Using:
OS X Version 10.4.2
ruby 1.8.2 (2004-12-25) [powerpc-darwin8.0]
MySQL 4.0.15
I’d previously followed the instructions for installing Ruby Gems and the instructions listed off http://tech.rufy.com/entry/46.
(Dave says: you need to update your Ruby client library.)
| 2005-07-27 | |
439 | 451 | TYPO | In the “input validation is difficult” box, you have “For example, if you strip out the string ../, a malicious input
such as ….// will still get though.”, probably should be “…get through”.
| 2005-08-10 | |
182 | | OK | “…controllers performing related but disjoint…” should read “…controllers performing related but disjointed…”
(Dave says: disjoint is correct (I believe). THe functions are disjointed—-they are unrelated, and hence are disjoint)
| 2005-08-08 | |
138 | | DEFER | You mention adding all three fixtures to the test case (:categories, :products, :category_products) and we have already covered products and category_products, but we don’t cover the ‘categories’ fixture. It’s fairly obvious what it might look like (history, programming, leisure), but it would be good to have it written out here so our test case would actually run the first time we try it.
(Dave says: it’s a fine line between being complete and being tedious. I believe Mike wanted to keep the ball rolling here. I might see if we can add a cross reference in a future edition)
| 2005-07-27 | |
137 | | SUGGEST | Actually, why are you discussing ‘category’ values here at all? A search shows that this is first reference to categories in the book - they’re added to the schema on Page 218. Was this chapter perhaps moved up to an earlier part of the book?
(Dave says: they’re here because Mike needed an example. It seems reasonable, particularly given the forward reference)
| 2005-07-27 | |
196 | | OK | def superuser?
self.superuser == ‘J’
Whiel you explain these boolean tests are DBMS and locale-dependent, this seems to violate DRY. If there’s no switch you can flip in e.g. environment.rb when you take your Dutch app to France, there must be a best practice to address this so you don’t have to manually edit all your models. And frankly, the 7 false values (0, “0”, “” etc) are perlish, is this a temporary state of affairs?
(Dave says: this is probably something you’d want to take up with the Rails team. They write ‘em, I document ’em :) FWIW, I kinda agree about the ’J’ thing, but it was really just an example of a custom predicate)
| 2005-07-27 | |
6 | | DEFER | Under “Rails Versions”, both “Rails V1.0” and “Rails 1.0” are referred to. I think the “V” is unnecessary, so standardising on “Rails 1.0” would be best.
(Dave says: indeed it would…)
| | |
13 | 15 | SUGGEST | The footnote defining SQL is actually attached to the second appearance of “SQL” on the page (4th para); it should probably be attached to where “SQL” is first used, which is in the second paragraph.
| 2005-08-10 | |
256 | 266 | TYPO | The paragraph prior to section 15.4 - Validation contains the word “stange” that should be “strange”.
| 2005-08-10 | |
195 | | OK | On page 194 you state tha account[:balance] is deprecated in normal code and that it is preferable to use account.balance instead. However, on page 195, in the “David Says” box, the example goes on to use self[:balance] = value. While it is perfectly fine, perhaps it would be better to make that self.balance = value so as to reiterate that the symbol version is deprecated?
(Dave says: if we did, we’d loop forever, because this is the method that implements self.balance =)
| 2005-07-27 | |
20 | | OK | Under 3.2 point 2, if OS X unpacks the archive, then there is no need to run the “tar” command.
(Dave says: actually, there is if it ends .tat.gz, as OSX only unzips it)
| 2005-08-06 | |
265 | 275 | ERROR | Figure 15.4 clearly contains 18 callbacks (8 each for the insert and update operations, 2 for the delete operation).
The text in paragraphs 2, 3, and 4 discusses only 16 of these callbacks. Furthermore, paragraph two mentions 14 callbacks that are before/after pairs and two exceptions (after_find and after_initialize) that aren’t present in figure 15.4, meaning that the paragraphs are only really discussing 14 of the shown 18 callbacks.
I’m sure it’s just a matter of the text and the figure being out of sync, but it’s very confusing for the reader (took me three reads just to make sure I wasn’t misunderstanding!).
| 2005-08-10 | |
45 | 49 | TYPO | After the figure, the text “shown Figure 5.1 ,” should be “shown in Figure 5.1,” — add “in” and remove space before comma.
| 2005-08-10 | |
423 | 435 | TYPO | para-mater should be para-meter. interesting to note too that the hyphenation breaks pdf searchability on the word
| 2005-08-10 | |
62 | 66 | ERROR | Protecting the database table from rows with price <= 0.0 does not work this way: If the user enters 0.001 or a smaller price > 0.00, then 0.00 will be stored in the database, since price is defined as decimal(10,2). At least with Postgresql, the value of price is rounded down to 0.00
(Dave says: oh! I like it. Thanks)
| 2005-08-10 | |
10 | | OK | The link to Figure 2.1 is below the figure, so when a user clicks on it, it moves the PDF back only enough to view the title - not the figure itself.
(Dave says: we had to choose somewhere to anchor the link, and the package we have defaults to the caption.)
| 2005-08-06 | |
398 | 410 | TYPO | Under web 2.1 heading:
The AJAX field is changing rapidly, and Rails is at the forefront. This
makes it hard to produce definitive docmentation in a book
| 2005-08-10 | |
153 | | OK | States that get (and other HTTP Request Methods) take 4 parameters (action, parameters, session, flash) but the examples appear to use a number of other params not mentioned (id, session_key, message). Should they have been wrapped in a hash as the “parameters” parameter? Or is my inexperience with Ruby showing through?
(Dave says: these are all a single parameter, turned into a hash)
| 2005-08-07 | |
53 | | DEFER | Regarding the /tmp/mysql.sock problem mentioned above. I had the same problem running on Fedora Core 4, there was no mysql.sock in /tmp.
I overcame the issue by using an IP address (127.0.0.1) in the database.yml file rather than localhost. You also need to alter the Mysql grant lines to use the IP address. This connects via TCP/IP rather than through /tmp/mysql.sock.
(Dave says: this must be some kind of mysl configuration thing. I’m not sure I can address it in the book, but the above is certainly good information to know)
| | |
88 | | OK | “If we look at the end of the log file…” - Actually, the end of the log file contains a stack trace resulting from not finding “/images/logo.png” - unless you just happened to add such an image when following the direction on page 65 to “Put some images” there.
It would be good to provide such a logo.png file and instructions to install it, so that the log file doesn’t fill up with these distracting error messages, and also so the screen shots better resemble what the user will see.
(Is there not one in the download?)
| 2005-08-07 | |
91 | | OK | The code fragment at the top of the page (“def empty_cart…”) doesn’t have a corresponding link to download the code.
(Dave says: code that doesn’t appear in an external, runnable application doesn’t)
| 2005-08-06 | |
34 | 36 | ERROR | (Last paragraph)
"One approach would be to embed a call to Ruby
| 2005-08-10 | |
99 | 105 | TYPO | Towards the bottom of the page:
“The first element of each subarray is the string to be displayed as option” =>
“The first element of each subarray is the string to be displayed as the option”
| 2005-08-10 | |
226 | | OK | 3rd paragraph, 2nd sentence: “:class_name” repeated.
——————-
As with has_one, you can modify Active Record
| 2005-08-08 | |
238 | 247 | SUGGEST | The example at the bottom of page 238 uses the validate() hook, which isn’t explained until page 257. That it is automatically called can be inferred, but a link and/or hint that validation hooks will be explained later would be helpful.
(Dave says: added expanatory comment)
| 2005-08-10 | |
339 | 351 | TYPO | “runnning” in the last paragraph should be “running” [Note the two consecutive “n”s instead of three]
| 2005-08-10 | |
388 | 400 | ERROR | The example of Effect.Scale on both the image and the div use a scaling percent of 100, which does nothing (on my browser, at least). Perhaps this should be a different number?
| 2005-08-10 | |
442 | 455 | SUGGEST | You should probably note that Apache 2.0 people should use mod_fcgid instead of mod_fastcgi. mod_fcgid is a binary compatible replacement for mod_fastcgi for Apache 2.0. Which works very well, I’ve had no depolyment problems.
| 2005-08-10 | |
53 | | OK | when trying to access http://localhost:3000/admin the scaffold shows New Product - but when i click on it i get an error on the next page “ActionView::ActionViewError in Admin#new” - No rhtml, rxml, or delegate template found for admin/_form - im running slackware linux 10.1 and installed everything via the instructions in the book
(Try downloading the code form the website and running that. If you still have problems, look in the log files. It might be a configuration issue)
| 2005-08-07 | |
448 | 461 | OK | "…we
| 2005-08-09 | |
69 | | OK | The www.rubyonrails.com site has a standards compliant design with a CSS-layout. Why not having standards compliant design in the template examples in the book too. Using the kind of obsolete HTML-code that I saw in the PDF-samples gives people the idea that the authors don’t even know how to write proper HTML. For me it’s really important with standards compliant design and if I wouldn’t know that this would be possible with Ruby on Rails I wouldn’t even be interested in it. Luckily the www.rubyonrails.com site is a living example of it being possible. :-)
(Dave says: the template code is generated by Rails, so there’s nothing I can do about it in the book. If there is book-specific code that isn’t compliant, let me know. And, lighten up :)
| 2005-08-07 | |
360 | 372 | TYPO | The second sentence in the paragraph starting “Idiomatic …” should be “In …” rather than “If …”.
| 2005-08-10 | |
372 | 384 | TYPO | “acessor” should be spelt “accessor” (first line of page).
| 2005-08-10 | |
387 | 399 | TYPO | The fourth sentence of the paragraph beginning “The screenshots …” has the text “it might remove a remove from a database table”; should be “it might remove a record from a database table”.
| 2005-08-10 | |
387 | 399 | DEFER | The code described as “File 194” has “<% 16.times do |i| …” which I think is trying to build a 4x4 series of squares, but the diagram on the following page (Figure 18.7)have only a 3x3. Should the “16.times” be “9.times”?
(Dave says: hmmm…. actually, the code in the book is what produced the window shown. I just sized the browser window to produce the list of 9 squares. That’s kinda confusing, I agree, but isn’t really an error. I’ll fix this in the next edition)
| | |
397 | 409 | TYPO | The sentence “If you want to different actions depending …” near the bottom of the page should have ‘use’ inserted, i.e. “If you want to use different actions depending …”.
| 2005-08-10 | |
402 | 414 | TYPO | The definition for “from = array or string" reads "... using the same format is recipients …”. The ‘is’ should be ‘as’, i.e. “… using the same format as @recipients …”.
| 2005-08-10 | |
486 | | OK | The depot_final code (from the website)does not pass rake. In test_units there is one error caused by orders.yml fixture being empty. This is fixed by copying the depot testing fixture. in Functional testing there are about 9 errors. I am not sure of the exact number as I am using postgresql and some of the errors may be due my having not translate from mysql to postgress correctly.
(Dave says: run the code in depot_testing instead)
| 2005-08-08 | |
357 | 369 | ERROR | “If the current request is being handled
by a controller called store, Rails will by default look for a layout called
store_layout (with the usual .rhtml or .rxml extension) in the app/views/layouts
directory.”
In the above sentence “store_layout” should just be “store.”
| 2005-08-10 | |
393 | 405 | TYPO | The word “trivial” is misspelled in the last line (before the code)
| 2005-08-10 | |
306 | | ERROR | In description of session_id, it calls it a “key”
In description of session_key it calls it an “id”.
| 2005-08-10 | |
80 | 85 | OK | In the definition of the ‘for_product’ method of the LineItem class on PDF (July 13) page 80, the method appears to be missing item.save to save the object to the database after it is initialized. If this is the case, then the source file (File 77) also needs to be changed to reflect this. If I add item.save to the method, then the line items are saved to the database. It’ll appear to work even if it isn’t saved because they are stored in memory. Perhaps it was accidentally omitted from the last line which is simple ‘item’? Apologies if I’m missing something.
(Te line items aren’t saved yet: they’re saved when the customer placed the order on checkout in the next chapter)
| 2005-08-10 | |
397 | | TYPO | Near the bottom of the page, “identified by the :url parameter.. If JavaScript” should read “identified by the :url parameter. If JavaScript” (with one period).
| 2005-08-10 | |
34 | | ERROR | In the explanation about HTML Entities and the h() function, it says
Ann & Bill <frazers@isp.email>
| 2005-08-10 | |
91 | 97 | OK | On the top of page 96, the definition for empty_cart uses “find_cart.empty!” but on the top of page 97, the definition has mysteriously expanded itself to be “cart = find_cart \
cart.empty!”. (I hope P1.0 is the correct version for the printed version of the book…)
(Dave says: reported and fixed between P1.0 and P2.0)
| 2005-08-18 | |
349 | | OK | The reference variable used for the select_hour/minute/second functions is time, but time was never initialized. I assume you mean either date, or wanted to set time = Time.now in the line above. This (error) exists in P2.0 as well.
(Dave says: the assignment isn’t setting a variable to be used later—it’s Ruby syntax that indicates the default value of a parameter)
| 2005-08-19 | |
| 412 | OK | There is an extra comma after the word “secret”
————————
ActionMailer::Base.server_settings = {
:address => “domain.of.smtp.host.net”,
:port => 25,
:domain => “domain.of.sender.net”,
:authentication => :login,
:user_name => “dave”,
:password => “secret”,
}
(Dave says: that’s a style I tend to use: it allows me to add new entries at the end)
| 2005-08-18 | |
| 287 | OK | “xxx_id
Default name of a foreign key reference to a table named with the plural form of xxx (page 225).”
According to the text on p225-226, the xxx should be the singular form (product_id, not products_id), as suggested on this page.
(Dave says: that’s right—the table is named with the plural form, as the text explains)
| 2005-09-13 | |
291 | 302 | SUGGEST | (bottom of page) “class BlogController < ActiveRecord::Base
def create_order…”
Perhaps, rename BlogController to OrderController?
(Dave says: oops)
| 2005-09-13 | |
122 | 129 | DEFER | See the last paragraph before the screenshot. Starts with the text "That
| | |
54 | 58 | OK | When trying to go to admin/new - get the same ActionView error: No rhtml, rxml, or delegate template found for admin/_form. Looking back, it seems that the ‘scaffold’ command didn’t output _form.rhtml.
(Dave syas: Perhaps you’re running an old Rails…)
| 2005-09-13 | |
81 | 86 | OK | Errr… no, I didn’t get the error - just a nice page showing that I had “1 items” in my cart - without having added the model : cart model :line_item to te Application Controller. Is this some new functionality for Rails perhaps?
(Dave says: yes — the latest version of the book reflects this. You still need the ‘model’ delcarations, though, unless you’re running the mythical Rails 1.0 release)
| 2005-09-13 | |
510 | 525 | TYPO | “Use the Holly Hack to fix layout bugs in IE on Windows” should be “IE on Macintosh”
| 2005-09-13 | |
510 | 525 | TYPO | “Shoppng cart screen” should be “Shopping cart screen”.
| 2005-09-13 | |
465 | 478 | TYPO | At the beginning of the second full paragraph on page 478:
“During their initial tests to ASSERT whether Rails was …”
“Assert” should be “ascertain”, “determine”, or some other word with
a similar meaning.
(Dave says: is should have been ‘assess’)
| 2005-09-13 | |
79 | | TYPO | The hyperlink to page 474 that describes the << operator points to page 473.
| | |
89 | 94 | OK | Looks like there’s an image missing from the page. There’s a giant gap of whitespace halfway down.
(Dave says: I’m guessing you’re using Preview on OSX, which has known bugs with larger PDFs. Try rebooting.)
| 2005-08-22 | |
159 | 166 | OK | In the middle paragraph, it says “sounds like we need another custom assertion”. It seems to me that it really should say “sounds like we need another helper method”. More custom assertions are created in the following paragraph, but they’re not related to the sentence that this phrase appeared in.
(Dave says: it’s simply a throwaway comment that we might want to think about creating an additional customer assertion in the future to eliminate this extra call)
| 2005-09-12 | |
307 | 318 | TYPO | When describing the DRbStore session, the heading (which indicates the appropriate line of code) is:
:database_manager => CGI::Session::DrbStore
whereas it should be:
:database_manager => CGI::Session::DRbStore
(notice the “DRb” rather than “Drb”)
| 2005-09-13 | |
169 | 176 | OK | In the code listing for the OrderTest unit test the class is not closed with an end after the setup and teardown methods are defined.
(Dave says: That’s right—it’s just a snippet to show those methods. If you click on the link next to it, you’ll get the full file)
| 2005-08-26 | |
395 | 407 | TYPO | The sentence above the last code block has: “… of the instance variable contents_of_page_scripts in the header.". " contents_of_page_scripts” => “@content_for_page_scripts”
| 2005-09-13 | |
291 | 302 | TYPO | First line: “… to these named route” should be “… to these named routes” (plural)
| 2005-09-13 | |
384 | 396 | TYPO | First line: “… a less attractive user interfaces” should be “less attractive user interfaces” (lose singular ‘a’)
| 2005-09-13 | |
i | i | OK | Dave says: For general help with Rails and examples in the book, I recommend the Rails mailing list at http://lists.rubyonrails.org/mailman/listinfo/rails
We need a forum for problems encountered while working through examples and better descriptions of how to fix the Mac Tiger mysql problems
| | |
202 | | OK | Page 202 states: “Note that in all of these examples we did not set the id attribute of the new row. Because we used the Active Record default of an integer column for the primary key, Active Record automatically creates a unique value and sets the id attribute just before saving the row.”
Many ORMs provide a facility for letting the back-end database auto-generate an integer primary key. Does Rails Active Record allow the back-end to autogenerate the integer primary key, rather than Active Record setting it? Or perhaps I misunderstood, and Active Record is actually letting the back-end db generate the primary key, and then using that to assign the object’s id.
(Dave says: it actually depends on the database, but the generation is not a user-level responsibility)
| 2005-08-31 | |
210 | | OK | I like methods such as find_by_name_and_password() - which finds based on MORE THAN ONE column, in this case name and password.
How does the programmer know whether to call find_by_name_and_password() or find_by_password_and_name()?
Are the column names concatenated into the method name in alphabetical order?
(Dave says: it doesn’t matter—Rails doesn’t pre-generate the methods. Instead it discovers them when you call them)
| 2005-08-31 | |
71 | 75 | OK | The sourcecode from index.rhtml does not show figure 7.2: Price and [Add to Cart] are not beneath the product description but right next to it.
(Dave says: they are if you have
tags around your product description in the database (which I do in this example :)
| 2005-09-13 | |
53 | 57 | OK | The current version of rails pulled down by
> gem install rails —include-dependencies
is 0.13.1 (code on p. 20).
This version breaks the scaffold generation command on page 62:
depot> ruby script/generate scaffold Product Admin
Specifically, this file is not generated:
app/views/admin/_form.rhtml
Uninstalling rails 0.13.1 and dependencies and installing 0.13.0 fixed the problem.
(Days says: that’s strange, as I demo using the current gem rails all the time. Either way, thoug, I suspect this is a problem with Rails, and not a book erratum)
| 2005-09-13 | |
40 | 42 | SUGGEST | There are a couple of small (read trivial) consistency issues with the code examples used for the hello.rhtml and goodbye.rhtml. The spacing for the line in goodbye.rhtml stating:
<%= link_to “Hello”, :action=>“hello” %>
is different than the spacing listed on the previous page (pg. 39) for the hello.rhtml counterpart:
<%= link_to “GoodBye!”, :action => “goodbye” %>
Also, in regards to the hello.rhtml, there is another nit picky issue of the wording “It is now <%= @time %>.” on page 39, versus what was listed earlier on page 34, where is says “The time is <%= Time.now %>”.
(Dave says: Ah, consistency… I really should work on it)
| 2005-09-12 | |
229 | 238 | TYPO | “…Constructs and save a new order object…” should be “…Constructs and SAVES a new order object…”
| 2005-09-12 | |
296 | 307 | TYPO | The second to last paragraph reads “If the parameter is :false, no layout will be applied.” it should be “If the parameter is false, no layout will be applied.”
Cheers!
| 2005-09-13 | |
| 224 | OK | At the bottom of page 224 (Chapter Deleting Rows) in the first sentence of the subsection after the code “# … order is now frozen” are described the two versions of delete, but in the text you found “destroy()” and “destroy_all()”. I think, there must stand “delete()” and “delete_all()”.
(Dave says: I believe it’s OK as it is. The text describes botht he destroy(0 and the delete() families of methods. Two paraggraphs before the paragraph you mention, it says that we’re switching from talking about delete to talking about destroy)
| 2005-09-08 | |
81 | 86 | ERROR | With Rails 0.13.1 it doesn’t give the error on p.86 but it will error adding the empty! method unless the ApplicationController is updated.
(Dave says: this is actually a bug in Rails, but I’ll document it as such in the book. The workaround is to include the “model :cart” line in application_controller.rb)
| 2005-09-12 | |
459 | 472 | TYPO | In chapter 22.6, paragraph 4 we can read “The first (and most imprtant) rule” but it should be “The first (and most important) rule”.
Now that I’m at the end of the book, I’ve got to tell you Dave that it’s a wonderful book. Thank you.
| 2005-09-13 | |
119 | 126 | TYPO | When creating the Login controller, logout is left out of the resulting response:
depot> ruby script/generate controller Login add_user login logout delete_user list_users
exists app/controllers/
exists app/helpers/
create app/views/login
exists test/functional/
create app/controllers/login_controller.rb
create test/functional/login_controller_test.rb
create app/helpers/login_helper.rb
create app/views/login/add_user.rhtml
create app/views/login/login.rhtml
create app/views/login/logout.rhtml <—- not printed in book
create app/views/login/delete_user.rhtml
create app/views/login/list_users.rhtml
| 2005-09-12 | |
328 | 340 | SUGGEST | The 5th line from the top has the string ‘controller/name’ in
non-italics, unlike the surrounding two lines. It appears
that all text in quotes is italicized.
(Dave says: there’s a missing quote)
| 2005-09-13 | |
368 | 380 | TYPO | The first paragraph of normal text has this sentence:
“The action view uses the read_fragment() method so see if..”
the “so” should be replaced with “to”.
| 2005-09-13 | |
102 | 108 | OK | In the discussion of error_messages_for, you say “Any errors…are saved with that model.” You then call error_messages_for(“order”), which happens to be the name of the model.
However, error_messages_for actually expects the name of the instance variable that you used in the controller… which in this case happens to be @order. The text is technically correct, but confusing.
Also, FWIW, you use three different styles to call e_m_f throughout the book - single-quote with no parens, double-quote with parens, symbol name.
(Dave says: when I say it’s stored with the model, I think it’s fairly clearly that this must mean it’s stored in an object somewhere. However, I’ll change the wording a tad)
| 2005-09-12 | |
333 | 345 | OK | <%= truncate(@post.body.capitalize, 30) %>
In the call out box present as a mailto: link in Acrobat reader 7.02 - not sure if this behavious can be changed, and not critical
(Dave says: that seems to be a bug in Acrobat—I’m not making it a link in the PDF file)
| 2005-09-13 | |
248 | 256 | OK | The sql code defining the table ‘categories’ defines ‘parent_id’ defines it without a ‘not null’. The constraint that defines the parent child relationship also would generally expect this. The data defined in the diagram 15.1 shows the first category (id=1) as having a (parent_id=null). This should not work, at least on postgresql it does not. This may be a MySQL’ism but I do not know. In my case I dropped the relationship and just documented it.
(Dave says: the parent_id column must allow null values, and hence is defined without the ‘not null’ constraint. I’m not sure I understand the issue here)
| 2005-09-12 | |
412 | 424 | SUGGEST | Footnote 1 credits Larry Wall for the rule ‘liberal in receipt, strict in emit’
It really should be credited to Jon Postel, it is often referred to as “Postel’s Law”. See RFC 791 and 793 for early usage of the concept.
| 2005-09-13 | |
451 | 464 | OK | In section 22.3 “Handling errors”. On the mentioned page is a code snippet how to override rescue_action_in_public(). This code snippet uses SystemNotifier.deliver_exception_notifictation(self, request, exception). However, the next text paragraph on the same page explaining that code snippet talks about “SystemNotifier is an Action Mailer class; its exception_notification() method…”, which is resembling, but not exactly the same as, the method call used in the code. This leads to the uncertainty whether the code is right, or the text.
NOTE: I received my paper copy yesterday after some delay, so I guess I have version P2.0, but I’m not sure.
(Dave says: remember—you prefix the name of mailer classes with ‘deliver’ or ’create’)
| 2005-09-13 | |
487 | 502 | TYPO | In the source file for ApplicationController the documentation says “establishes Cart, LineItem, and User as models”. Shouldn’t it then declare
model :cart
model :line_item
model :user
?
(Dave says: the comment was wrong. User isn’t needed)
| 2005-09-13 | |
398 | 410 | TYPO | “Thomas Fuch’s website” should be “Thomas Fuchs’s website”
And sorry for the dup that I just submitted for a different erratum.
| 2005-11-07 | |
352 | 364 | TYPO | In the sentence “Finally, we can implement the show action, which displays the command and the image.”, “command” should be “comment”.
| 2005-11-07 | |
369 | 381 | TYPO | In the 2nd sentence of the 2nd paragraph, which says “For example, when we edit a fragment, we have the expire the article list, but the count is still valid.”, the word “fragment” should be “article”.
| 2005-11-07 | |
| 382 | OK | Does RDoc handle substitution of values from the local variable hash? If not, this should be stated.
(Dave says: no - it’s a basic example to show a trivial template handler. Extending it to support substitution si fairly simple, but (as they say) left as an exercise for the reader)
| 2005-09-15 | |
| 107 | ERROR | In the sample code available here on the website, as of 9/15/05 you include some SQL code to fill up the products table of the depot application with fake products (db/product_data.sql in depot12 onward.) The problem comes when the user has a MySQL database with InnoDB tables (which is the default on the Windows binary, at least.) The fake product SQL first drops the products table and then recreates it, specifying MyISAM as the table type. Because the line_items table has a foreign key that references the products table and because MyISAM doesn’t support foreign keys, if the user has a InnoDB line_items table and a MyISAM products table then trying to insert data into the line_items table will fail since MySQL can’t resolve the foreign key.
The solution would be to either have the fake products SQL specify InnoDB as the table type, not specify a table type at all or to not even bother with recreating the products table.
(Dave says: This whole MySQL table type thing is a real mess. I might switch to SQ@Lite to avoid it in future. Anyway, for now I’ve simply dropped the table type)
| 2005-11-07 | |
337 | 349 | TYPO | The helper for doing textile conversion is called ‘textilize()’, not ‘textile()’
| 2005-11-07 | |
53 | | DEFER | On Mac OS X I was getting the error "Access denied for user
| | |
179 | 186 | ERROR | The text suggests the command “depot> ruby script/server -e development | test | production”. Apparently, you intended the vertical bars to separate alternatives. However, this is not clear and a user who types in this command will not like the result.
Please try for a less ambiguous presentation.
| 2005-11-07 | |
81 | | ERROR | An extension to the other reports about the model declarations being needed even with rails-0.13.1 (on OSX), without the model declarations the line:
item = @items.find {|i| i.product_id == product.id}
will not function as intended so each item will add a new row instead of incrementing the quantity. Took me a while to track that one down!
| 2005-09-26 | |
291 | 302 | ERROR | “class BlogController < ActiveRecord::Base” should probably be “class BlogController < ApplicationController”
(Dave says: Actually, should be OrderController… :)
| 2005-11-07 | |
| 116 | OK | OK. I’ve been following along and now I want to use the create.sql script in Chapter 10 (Task E, Iteration 1). I’ve downloaded the source from the web site, but it isn’t obvious how the different depot directories map to the iterations in the book. Since you have the chapters split up by Tasks (A-F) with various iterations, having the example source as depot_E1 would help me match them up.
I’d just run the db/create.sql script from there.
(Dave says: the cross reference of file names in the appendix should help)
| 2005-09-26 | |
| 133 | OK | We now have this functionality of requiring us to login before we can get to the ship page. However, when I see the store status with my total and pending orders, the links in the side bar to “Products” and “Shipping” don’t work.
(I think they were remaining in the Login controller)
I went back into the admin.rhtml and added:
:controller => “admin”
to both of the link_to elements.
Is this the correct solution?
(Dave says: that’s what’s done on the next page…)
| 2005-11-07 | |
138 | 145 | TYPO | “Simple” is used in place of “simply” in: "The first assertion in the preceding code simple means expect the product id to be 1, and complain if it isn
| 2005-11-07 | |
187 | 195 | TYPO | There should only be one period at the end of 3rd paragraph from the bottom “with the normal WEBBrick tracing..”.
| 2005-11-07 | |
| 151 | TYPO | Maybe I’m not quite understanding what Mike is saying (in the context of using a dynamic fixture to ‘future-proof’ the test of salable_items). He says “Perhaps we should refactor the salable_items() method to take a date as a parameter. That way we could unit test the salable_items() method simply by passing in a future date to the method…”.
It would seem that instead of passing in a ‘future’ date. You’d want to send in a known, fixed, date that would be prior to the one in the fixture for the future-proof book.
I’m thinking it as salable_items AS OF a supplied date,
and typically it would be today’s date in production, but could be fixed for tests.
| | |
| 167 | TYPO | Looking at the log/test.log file after executing the test_save_valid_order: Mike’s output has “shipped_at” fields filled in. Newly created orders shouldn’t be marked shipped.
My log shows a NULL being passed:
INSERT INTO orders (`name`, `shipped_at`, `pay_type`, `address`, `email`) VALUES ('Fred', NULL, 'check', '123 Rockpile Circle', 'fred@flintstones.com')
| 2005-11-07 | |
| 173 | DEFER | I run ‘rake test_units’ as instructed and get an error because the line_item_tests (which we haven’t modified) fail. This appears to be due to a foreign key constraint triggered by the line_items fixture.
1) Error:
test_truth(LineItemTest):
ActiveRecord::StatementInvalid: #23000Cannot add or update a child row: a foreign key constraint fails: INSERT INTO line_items (`id`) VALUES (2)
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/connect
ion_adapters/abstract_adapter.rb:462:in `log’
(Dave says: we’re going to rewrite this chapter to use transactional fixtures and work out these kinds of issues)
| | |
| 176 | DEFER | The performance test doesn’t run.
1) Error:
test_save_bulk_orders(OrderTest):
ActiveRecord::StatementInvalid: #23000Cannot delete or update a parent row: a foreign key constraint fails: DELETE FROM orders
If I add “LineItem.delete_all” in the teardown before the Order.delete_all, it seems to work.
| | |
| 66 | OK | The validate method does not need price.nil? test. In…
errors.add(:price, “should be positive”) unless price.nil? || price > 0.0
all you need is the price > 0.0 test. BTW price.nil? will be false for all values < 0, =0 and >0.
(Dave says: But price will be nil if no price was entered, and if that’s the case the comparison with an integer will raise an exception)
| 2005-09-29 | |
50 | | OK | Minor mysql quibble. You should “flush privileges;” after your grant statements and before your exit to make sure they take effect immediately.
(Dave says: That’s no longer true. You need it if you insert into the user table, but, from the MySQL manual: “With GRANT, FLUSH PRIVILEGES is unnecessary.”)
| 2005-10-07 | |
| 138 | DEFER | The code on page 138 of the book is incorrect
redirect_to(jumpto) will not work if jumpto contains nested hashes. For example, if jumpto contains this post hash, it will not work.
{“commit”=>“ask”, “post”=>{“title”=>“asdfsdfs”, “body”=>“asdfsdf”, “price”=>“345”, “tags”=>“#finance ”, “email”=>“myemail@gmail.com”}, “action”=>“postQ”, “controller”=>“ask”}
will result in request_to flattening it down to
{“commit”=>“ask”, “post”=>“titleasdfsdfsbodyasdfsdfprice345tags#finance emailmyemail@gmail.com”, “action”=>“postQ”, “controller”=>“ask”}
| | |
| 183 | OK | Fig 13.2 has wrong labels for folder names.
This was reported before…and I had to check each version to see that. So how about a cumulative, reported errors page?
Also all the figures from chapter 13 onwards in the ver3 of my PDF do not have any text in them (the earlier verions do)
(Dave says: click on the drop-down at the top of the errata page to go back to prior versions)
| 2005-10-07 | |
141 | | DEFER | The code in the test_read_with_hash method failed because the numbers (id) needed to be converted to int and the price needed to be converted to float (to_i and to_f respectively). Once I added those methods to the vc_book[“id”] and vc_book[“price”] fields, the test passed. I’m using a CSV fixture, not YAML. The YAML fixture gave me problems on my WinXP machine.
(Dave says: this is presumably an inconsistency between the fixtures, rather than an error in the book. Perhaps a future edition should add a paragraph or two on the CSV fixture)
| 2005-10-09 | |
342 | 354 | ERROR | The update_attributes method calls save, so the save shown is redundant. Should be:
if user.update_attributes(params[:user])
…
end
| 2005-11-07 | |
225 | 229 | ERROR | class LineItem < ActionRecord::Base and class Order < ActionRecord::Base should be class LineItem < ActiveRecord::Base and class Order < ActiveRecord::Base.
| 2005-11-07 | |
| 129 | OK | While following Iteration F1, I am having trouble with the part of moving “redirect_to_index” from the Store controller to the Application controller.
When I do this and submit the form for add_user, I get the following error:
Unknown action
No action responded to index
No where in the tutorial am I told to create the index method in Login controller or the index.rhtml in the login view directory.
(Dave says: it explains this at the top of the next page)
| 2005-10-21 | |
439 | 451 | TYPO | “I often check that dirname(full_file_name_from_user) is the same as the
expected directory. That way I know that the filename is hygenic.” => hygenic is written hygienic correctly.
| 2005-11-07 | |
| 57 | OK | regarding the __form missing error, reported twice above, I had that error, and a little testing found it is caused by running:
script/generate scaffold Product Admin
rather than
ruby script/generate scaffold Product Admin
don’t know why the difference, but maybe this will help someone
| 2005-10-21 | |
131 | 138 | ERROR | inside the inner if statement (if logged_in_user) the session assignment should be:
session[:user_id] = logged_in_user.id
like in previous code samples in the book :)
| 2005-11-07 | |
| 159 | OK | perhaps you should also include a test for the functionality of the magic post-login redirect you spoke about on page 137. here is the test case I wrote to test the forward functionality:
def test_login_with_valid_user_with_redirect
get :add_user
assert_redirected_to :action => “login”
post :login, :user => {:name => ‘fred’, :password => ‘abracadabra’}
assert_redirected_to :action => “add_user”
assert_not_nil(session[:user_id])
user = User.find(session[:user_id])
assert_equal ‘fred’, user.name
end
(Dave says: we could do, but that code isn’t actually in the application)
| 2005-11-07 | |
| 137 | OK | running depot> rake appdoc on Windows produces the following error:
rm -r doc/app
rdoc -o doc/app —line-numbers —inline-source —title ‘Rails Application Docume
ntation’ -T ‘html’ doc/README_FOR_APP app/controllers/admin_controller.rb app/co
ntrollers/application.rb app/controllers/login_controller.rb app/controllers/sto
re_controller.rb app/helpers/admin_helper.rb app/helpers/application_helper.rb a
pp/helpers/login_helper.rb app/helpers/store_helper.rb app/models/cart.rb app/mo
dels/line_item.rb app/models/order.rb app/models/product.rb app/models/user.rb
rake aborted!
undefined method `exitstatus’ for nil:NilClass
Related to http://dev.rubyonrails.com/ticket/2018, so it isn’t a problem with the book, just the current version of rails. But it still had my head scratching.
| 2005-10-21 | |
328 | 340 | TYPO | “The controller objects headers, params, request, response, and session…” should probably be “The controller object’s…”
| 2005-11-07 | |
| 96 | DEFER | in the action add_to_cart we have a rescue that states in the logger.error “Attempt to access invalid product #{params[:id]}”
…thats not neccessarily true in my case the error occured somewhere in the find_card so it got me totaly confused.
Shouldn’t the rescue be limited to “product = Product.find(params[:id])” excluding the next two lines?
Something like:
def add_to_cart
begin
product = Product.find(params[:id])
rescue
logger.error(“Attempt to access invalid product #{params[:id]}”)
flash[:notice] = ‘Invalid product’
redirect_to(:action => ‘index’)
return
end
cart = find_cart
cart.add_product(product)
redirect_to(:action => ‘display_cart’)
end
| | |
338 | 350 | TYPO | In the example,
link_to(image_tag(“delete.png”, :size=“50x22”)
it should be :size => “50x22”
| 2005-11-07 | |
| 57 | OK | Slight variation on an error that has been reported several times. I’m using ruby 1.8.3, and rails 0.14.1.
On Page 57, after typing:
ruby script/generate scaffold Product Admin
No admin view gets created at all, app/views/products does. I didn’t notice this at first, but when I got a routing error Recognition failed for “/admin” that lead me to it.
On a hunch, I connected to http://localhost:3000/products, and the application came up beautifully!
A lot must have changed in the newer version of rails.
(Dave says: appears to be a bug in Rails: http://dev.rubyonrails.org/ticket/2538)
| 2005-10-21 | |
29 | | OK | Another take on the error of gem install rails —include-dependencies
I have three separate windows computers with the same issue (one with win98se, other with XP Pro SP1 and the last one with SP2, all with ruby 1.8.2
((Dave says: you need a more recent version of RubyGems to support the —include-dependencies flag)
| 2005-11-07 | |
53 | | OK | If after following all of the helpful info here and in the book, you STILL have no joy, make sure irb is installed. This is a dependancy of the rdoc package, easily installed on FC4 using ‘yum install rdoc’. I now have an http://localhost:3000/products page showing up!
More info at:
http://www.codepilots.co.uk/blog/archives/2005/01/08/ruby-on-rails/#comments
| 2005-11-02 | |
363 | 375 | ERROR | example for render_component
render_component(:controller => :store)
does not work
It will work with string instead of symbol…
render_component(:controller => “store”), as per API Doc example
| 2005-11-07 | |
207/208/209 | | OK | Something in Page 207/208 causes the evince(in Ubuntu Linux) PDF reader to close at full screen. (Or at resolutions of 125%+ ) And when trying to restart it from command line and then opening the PDF it returns a “memory error”. If you have it on page 207 or 208 (full screen) it closes out. When you try to open it by clicking on the icon, it opens and closes immediately (memory error) In gpdf the table on page 209(at the top of the page, doesn’t show up with the values filled in. Just as a blank table, with one exclamation point on each row.
(Dave says: try it with acroread: most open source PDF tools seem to be buggy: we’ve had to switch to Adobe products to generate our books because of random crashes)
| 2005-11-02 | |
| 54 | DEFER | Now that MySql 5.0 is “generally available”, novices to MySQL may encounter an ERROR 42000: Can’t find any matching row in the user table. This is because GRANTs to a non-existant user no longer create that user(http://bugs.mysql.com/bug.php?id=7000)
Future versions should probably demonstrate how to create the databases using GRANTS for version prior to 5.0.2 and using the CREATE USER statement (http://dev.mysql.com/doc/refman/5.0/en/create-user.html) for MySQL 5.0.2 and later. (Confirm that 5.0.2 was when GRANT changed to no longer adding users if they did not exist).
| | |
53 | | OK | After successfully running the command “ruby script\\generate scaffold Product Admin”, my controller is located at “http://localhost:3000/products” rather than “http://localhost:3000/admin” as the book suggests. I tried deleting my rails project, and recreating it, but to no avail. I’m running Ruby 1.8.2 on WinXP.
(Dave says: Update to the latest Rails)
| 2005-11-07 | |
53 | | DEFER | This is a follow-up to my post of earlier this morning.
I don’t know whether it’s definitive, but I’ve found a solution that works for me: http://www.pjhyett.com/articles/2005/06/04/setting-up-ror-in-tiger.
I’m glad to have found this, but it took uncomfortably much digging, so I hope you’ll add a pointer to this site in the next release of the book, if the problems haven’t been fixed (by Apple and anyone else at fault) by then.
| | |
62 | 69 | SUGGEST | At bottom of page 69 yous suggest to add some image … well it’s nice BUT ….
since at botom of page 66 page you make us write a validates rule where image_url must begin with http: i don’t realy know what to append in the input field image_url to point out the right image … is that http://localhost:3000/public/images/toto.png or whatever ?
you should there help us in the deep with an example i suggest …
(sorry but i’m not a good english speaker … d
| 2005-11-07 | |
395 | 407 | TYPO | In the paragraph between the two code blocks, contents_of_page_scripts should be content_for_page_scripts
| 2005-11-07 | |
142 | | ERROR | Fixtures no longer create instance variables. This affects the whole explanation of fixtures and unit testing between pages 136 and 148 including all sample code.
See
http://www.clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting
(Yes, testing will be changed in a future edition)
| 2005-11-02 | |
20 | 22 | ERROR | Context:
3.2 Installing on Mac OS X
…
2. Next you have to install RubyGems. Go to … OS X will typically unpack the archive file for you, so all you have to do is navigate to the downloaded directory and (in the Terminal application) type
dave> tar xzf rubygems-0.8.10.tar.gz
dave> cd rubygems-0.8.10
Technical error:
If you’ve already navigated (as instructed) to the unarchived (described as done automatically by Safari, depending on your preferences) directory, the above two commands are redundant.
| 2005-11-07 | |
| 69 | SUGGEST | In order for the view and css changes to take effect, I had to restart the webserver.
(Probably a caching issue in your browser)
| 2005-11-07 | |
| 5 | OK | cross reference to appendix in margin refers to ‘:name’. It should be ‘symbol’ which is the concept that is being cross referenced.
(Dave says: but if you know what a symbol is, then you won’t need the cross reference… :)
| 2005-11-02 | |
121 | | OK | File 54 and sample code within page 121:
def before_create
self.hashed_password = User.hash_password(self.password)
end
Should be self.hash_password = User.hash_password(self.password)
Otherwise, you end up with a nasty error:
NoMethodError (undefined method `hashed_password=’ for #):
(Dave says: I don’t believe so)
| 2005-11-02 | |
141 | | DEFER | With the new testing rules, a good chunk of the Testing chapter (with regard to fixtures and transaction vs. instantiated testing) is now incorrect. Will this be updated for Rails 1.0 in this edition of the book?
(Dave says: yes)
| 2005-11-02 | |
20 | | OK | to help those who’re stuck with the ‘—include-dependencies’ error (I had it as well on Win2000), here’s a fix:
’ gem install Rails -b -v 0.12.1 ’
where ‘0.12.1’ is the latest rails version.
have a nice time!
(Dave says: you need a more recent version of RubyGems to support the —include-dependencies flag)
| 2005-11-07 | |
328 | 340 | TYPO |
Request
<%= debug(request) %>
Params
<%= debug(params) %>
Response
<%= debug(response) %>
request, params, response should be member variables request, params and @response.
(Dave says: actually, just @request, and it was a Rails bug. It’s been fixed in RC4)
| 2005-11-07 | |
203 | 212 | ERROR | Code example in Reading Existing Rows has a comment that is inconsistent with the code. (Maybe because some code got chopped off?)
| 2005-11-07 | |
48 | | ERROR | "Finally, you might have noticed that I
| 2005-11-07 | |
| 1 | DEFER | For the next version a few plug-in examples would be nice
| | |
246 | 256 | TYPO | g missing in category “top-level cateory” -> “top-level category”
| 2005-11-07 | |
221 | 230 | TYPO | One-toOne Associations:
“… (the foreign key will be set to zero)”. Null, surely.
Also applies to Figure 14.4
| 2005-11-07 | |
340 | 352 | TYPO | In section 17.7, in the definition of user_list it shows the option “:order_by”. The correct option is “:order”. Under ActiveRecord 1.12.0 using “:order_by” will cause an exception. Silently ignored before that (but doesn’t sort).
| 2005-12-20 | |
110 | | OK | In the sample data at the bottom of the page which could be saved as db/product_data.sql the image URLs don’t start with http://, but my peoduct.rb model still says
validates_format_of :image_url,
:with => %r{^http:.+\\.(gif|jpg|png)$}i,
:message => “must be a URL for a GIF, JPG, or PNG image”
Does this matter, should they be http://localhost:3000/…, or should I just read on…
(Dave says: in the new printing I removed the http:// validation from that attribute)
| 2005-11-16 | |
315 | | OK | In compress() of CompressController, should ‘def output.close’ be ‘if output.close’?
(Dave say: no - it’s a singleton method on the output object)
| 2005-11-16 | |
68 | | OK | Spelling mistake, the word “salable” should be “saleable”.
| 2005-11-16 | |
| 64 | DEFER | This is the first mention of validation that I saw in the book. I’m experimenting with a database containing constraints and the question that came to mind immediately was “Does/can Rails validation work with the database’s constraints?” I’m not sure an in-depth explanation is appropriate this early in the book, but at least a one-liner similar to “See page whatever for information on the relationship between constraints and validation”
| | |
1 | | SUGGEST | The title field for the PDF version of this book is “Agile Web Development with Railspdfsubject” — the “pdfsubject” at the end shouldn’t be there, but this isn’t a major problem.
| 2005-12-19 | |
| 448 | OK | shouldn’t
user.orders.find(params[:id])
be
user.find(params[:id]).orders
(Dave says: no — that’s the whole point. We constraint the serch to orders for a particular user)
| 2005-11-16 | |
328 | | DEFER | Discussion of templates leaves out the rules for comments. I went nuts for two days trying to find the syntax error when
my html comment was perfectly fine, surrounding the erb delimiters. That doesn’t work and it seems like a bug. The ruby manual mentions putting the hash mark after the percent-sign in the beginning and that works.
The rails book leaves that out.
| | |
| 84 | OK | It says:
Let’s start off with the Cart class and its add_product
method. As it stores application data it is logically
part of our model,
At this point in the tutorial, two modules have been created, the Product model and the LineItem model.
The quoted phrase should specify which model it is referring to or be replaced by something clearer.
(Dave says: it’s part of “the model”, not a particular model class)
| 2005-11-16 | |
447 | | OK | "While it might sound dandy having Apache take care of process loading, in reality it isn
| 2005-11-16 | |
68 | 72 | SUGGEST | Salable is the correct spelling of items that are available for sale. This has been checked in the dictionary
| 2005-11-16 | |
| 407 | OK | The code on page 407 uses the script.aculo.us library and so requires <%= javascript_include_tag :defaults %> in the HEAD section of your page (i.e. in the layout) rather than <%= javascript_include_tag “prototype” %> as instructed on page 388.
(Dave says: It’s included by the fragment at the bottom of the same page, which does include the correct sciptaculous libraries)
| 2005-12-20 | |
| 551 | DEFER | It would be nice if the RecordNotFound exception was included in the index, as the RecordInvalid exception is. The index entry could refer to the “Reading Existing Rows” section on page 212 and also the “To Raise, or Not to Raise?” sidebar on page 219. In the absence of an entry for RecordNotFound, I used the index entry for the find() method, which references page 212 but not page 219.
| | |
| 551 | DEFER | New index entry for RecordNotFound exception could also reference the “Iteration C2: Handling Errors” section starting on page 91.
| | |
81 | 88 | OK | I want to add to this entry:
“#1418: I had to restart the WEBrick server to see the new cart display after adding the check to see if we just need to update the quantity of an item.—Andy”
I also had to restart the server. To fix this, add
require_dependency “cart”
to the top of store_controller.rb.
Dave says: the current version of the PDF fixes this)
| 2005-12-19 | |
131 | 138 | OK | In the login code example, line 9 has a missing id method that is present in the final source but not in the shown code.
Old:
session[:user_id] = logged_in_user
Fixed:
session[:user_id] = logged_in_user.id
(Fixed in previous release)
| 2005-12-20 | |
333 | | OK | Quote: PHP has Smarty, Java has Velocity, Python has Cheetah.
I don’t think this is directly comparable. You’re comparing here a framework (Rails) with programming languages! I don’t know about the Java and Python environment, but in PHP Smarty is only some sort of a template engine! PHP can be used for Rails-like templates, it even was invented for this sort of static templates with some dynamic content.
You can create a framework in PHP like you can create one in Ruby, and you can use PHP as a template language like you can use Ruby. So your compare is “hobbling”, you see what I mean?
You might wanna correct this inaccuracy. Anyway great book! :-)
(Dave says: my reading is that we’re comparing the Rails templating system with templating systems in other languages. You could write something different in those languages, but when this sidebar was written, the comprison was valid)
| 2005-12-20 | |
| 68 | OK | Sampl code for Product Listing doesn’t dispay images.
Line 11 read - <img width=“60 height=”70" src=“<%= product.image_url %>”/>
Should read - <img width=“60 height=”70" src=“<%= product.image_url %>”>
… No forward slash at the end.
Dave says—-It’s an XHTML thng, closing the tag. If it doesn’t work for you, try putting a space before the slash.
| 2005-12-19 | |
| 259 | DEFER | Love the book, it’s somewhat warn now!
It would be great if you could include end to end examples of Localization; example: SQL date in the DB, display, edit UK style date.
Secondly, and more important, end to end use of composed_of - again show and update of a composed_of field using rhtml
Many thanks
| | |
| 518 | OK | Label “File 124” is missing for depot_testing/test/unit/product_test.rb
(Yeah—it’s overwritten by the ‘require’ thingy. Sorry)
| 2005-12-20 | |
| 151 | DEFER | I agree with Richard Jensen’s comment, the paragraph beginning “While the use of time is a convenient way of demonstrating a dynamic fixture…” is confused:
1) It would seem that Mike would need to pass in a past date (rather than future date) to test his revised salable_items().
2) While I believe Mike’s general statement that unit tests can provide insights on how to better refactor the code, in this specific case, I don’t see it. Adding a date parameter to salable_items() is gratuitous as far as the application itself is concerned. Are we really going to ask (from the application) “which items are salable tomorrow (or yesterday)?” If so, then yeah, we need the date parameter. Otherwise, I’d argue that it’s not worth increasing the application’s complexity/potential sources of error just to make testing it trivially easier.
…But (like Richard) I wonder if I’m missing Mike’s point…
| | |
99 | 105 | SUGGEST | In the first paragraph, you talk about using the form_tag Rails helper method. But, in the code that follows, you use start_form_tag. Although one is an alias for the other, it is apt to confuse a new user.
| 2005-12-20 | |
| 98 | ERROR | using the fmt_dollars(item.unit_price) method, values less than 1, (values < 1) on the display_cart details show up as 0.00 but get added correctly to the total.
| | |
149 | 146 | DEFER | When you start calling the test_delete and test_read_with_hash methods the code breaks. In order for the code to work you have to put the following lines at the top of your unit test:
\tself.use_transactional_fixtures = false
\tself.use_instantiated_fixtures = true
(Agreed—this is a change in Rails since the book was written)
| | |
112 | 118 | SUGGEST | The following sentence is maddeningly unclear:
The “order_line” parameter also tells Rails to set a local variable called order_line to the value of the order currently being rendered.
Is this because the variable is NAMED order-underscore-lined or what? Or does it simply become .each member of the collection? If it’s the .each member of the collection then it’s not the “order_line parameter” that tells Rails to set a local variable, it’s the collection that tells this to Rails.
The text is breezy but not precise.
| 2005-12-20 | |
76 | 81 | OK | In the implementaion of find_cart, the 3rd line reads “session[:cart] ||=Cart.new”
This line should read “@cart = session[:cart] ||= Cart.new”, it is correct in the back of the book on p507
Dave says—-actually, that change comes later in the chapter. For now, it’s correct as it is.
| 2005-12-19 | |
53 | | DEFER | This not so much a new erratum as a request that erratum #1073 on page 53 of the PDF file be explained in more detail than it currently appears. This is the “Access denied for user ��@�localhost� (using password: NO)” problem on OSX 10.4. Please explain where the file to be patched resides, how to recompile it - which version of gcc - and anything else that needs to be done. I’ve been trying to generate a scaffold for three weeks now and researching the issue on the web I’ve found a lot of other people who are running in circle like me: we could really benefit from a more detailed and comprehensive tutorial on how to get RoR to play nice with MySQL on OSX 10.4+
| | |
140 | | DEFER | “Here�s the bottom line: even if a test method updates the test database,
the database is put back to its default state before the next test method is
run. This is important because we don�t want tests to become dependent
on the results of previous tests.”
I am having trouble with this… I moved the test_destroy method above the test_update method, and the test_update method fails because it can’t find a product with id=1. The database table doesn’t seem to be restored between tests.
(This is probably due to a change in the Rails defaults since the book was written. We’ll make all this clearer in the next edition)
| | |
345 | 357 | ERROR | Hello,
On the above mentioned pages, Common options for Text Fields are describe:
Common options include :size=> “nn” and :maxsize=> “nn”.
The attribute maxsize does not exist. You must be referring to the maxlenth attribute.
Thanks for your great work!
Best regards,
Tobie
| 2005-12-20 | |
| 53 | DEFER | Running OS X 10.4.3 and following all the directions in this chapter, I get to the place where I’m generating the scaffold and nothing works correctly. Others here have reported finding their proper directory at another location but whether I type http;//localhost:3000/admin or http://localhost:3000/products, I get the same error:
Routing Error
Recognition failed for “/products” (or “/admin”)
I noticed that one response here was to get the latest Rails. I’m running 1.8.2 (2004-12-25) [powerpc-darwin8.0], which as far as I can tell is the latest released version of rails unless I’m just not understanding something. At least, I got this version by following the directions in the Pragmatic book, which to this point is the only source of information on which I’m relying.
I know my MySQL database is running and can be connected to. This appears sto be a problem of the generate script but I’m darned if I can figure out what should be going on here. I want to fall in love with Rails, but so far, she’s jilting me!
| | |
380 | | ERROR | Note page# is acrobat reader page# - number in header is 380
The Observer code in this section does not work. To cut a long story short the parameters get mangled when they are retrieved using @phrase = request.raw_post || request.query_string so that if you type in an r a r&_ gets sent. Instead you need to
1) Use @phrase = params[:search_text]
2) Use a :with parameter with observe_field e.g.
:with => “‘search_text=’ + escape(value)”
There is stuff on the wiki about this.
It would also be good if this section explained about the CTAGS code being generated by observe_field
Rails 0.14.3
Ruby 1.8.2
Windows XP
| | |
131 | 138 | ERROR | In the code for Erik Hatcher’s suggestion, there is one remaining error keeping this from working as printed:
@user = User.new(params[:user_id])
should be:
@user = User.new(params[:user])
(the param should be user not user_id)
This error is also on page 138 of the first edition of the print book, but since I don’t own more recent books, I can’t tell you the page number for them.
| 2005-12-20 | |
20 | | DEFER | Linux Redhat FC4, doesn’t install what you expect when you install ruby via YUM. To get a more complete ruby install type:
yum -y install ruby rdoc irb
otherwise you get strange errors when you install rails while it installs the rdocs.
| | |
52 | | DEFER | For P53 to work on Fedora Linux FC4, it appears one has to install the mysql gem. Unfortunately that won’t build unless you have previously installed ruby-devel and mysql-devel. And even then it won’t build without passing extra parameters:
yum -y install ruby-devel mysql-devel
sudo gem install mysql — —with-mysql-lib=/usr/lib/mysql
After you follow these steps, the basic admin app works.
| | |
| ii | DEFER | Please put a list of Rails reserved words inside the front/back cover.
Maybe with a footnote to never use them as column headings in your tables.
I spent the last hour chasing down the error caused by using “method”.
Anyway, thank you for a much better than average computer book.
| | |
| 391 | ERROR | The AJAX example using form_remote_tag() on pages 391-392 doesn’t work. I downloaded the code directly from the website and tried it on Windows XP SP2 with Ruby 1.8.2-15 and Rails 0.14.4 running on WEBrick and Apache, using IE6 and Firefox 1.5 to browse, and on OS X Tiger.
The code is supposed to update a <div id=“update_div> with a new form using AJAX. Instead of updating the ”update_div" like it should, it renders the form as an entirely new page by itself.
WEBrick output:
127.0.0.1 - - [12/Dec/2005:10:43:28 Eastern Standard Time] “GET /guesswhat HTTP/1.1” 200 851
- -> /guesswhat
127.0.0.1 - - [12/Dec/2005:10:43:28 Eastern Standard Time] “GET /favicon.ico HTTP/1.1” 200 0
- -> /favicon.ico
127.0.0.1 - - [12/Dec/2005:10:43:32 Eastern Standard Time] “POST /guesswhat/guess HTTP/1.1” 200 623
http://localhost:3000/guesswhat -> /guesswhat/guess
It goes from “- -> /guesswhat” to “http://localhost:3000/guesswhat -> /guesswhat”, which leads me to believe that something in Rails changed that is causing a misdirection somehow.
| | |
226 | 235 | TYPO | line 1: s/that/than/
| 2005-12-20 | |
53 | | DEFER | On OSX Tiger (10.4.3) - Ruby 1.8.2 - Rails 1.0.0 - MySql 5.0
I was blocked using this command:
ruby script/generate scaffold Product Admin
blocks on line:
create test/fixtures/products.yml
To be fixed, user should install mysql gem using following command:
sudo gem install mysql — —with-mysql-dir=/usr/local/mysql
| | |
| 146 | DEFER | Further to Mark’s suggestion it is probably better to update the test/test_helper.rb file, which is where these values are explicitly set.
| | |
| 122 | DEFER | It looks like the pluralize method added to the controller is designed to provide you feedback even if you’ve checked no items to ship (the when 0 case formats it nicely). However, this will never get displayed, because flash.now is set only if count > 0 up in the ship method. Getting rid of the if clause around the setting of flash.now fixes this, and you get notified if you hit the ship button with nothing checked. I suspect this was the original intent; I certainly like it better that way.
Also note that this change doesn’t cause a spurious notice to appear when you first reach the shipping page; that’s prevented by the outer if statement in which things_to_ship is assigned.
| | |
143 | | SUGGEST | If you make a mistake in the yaml for the entry @future_proof_book, you won’t be told if it doesn’t exist and it will silently pass as it resolves to nil. I added:
unavailable_item = @future_proof_book
assert_not_nil unavailable_item
assert !items.include?(unavailable_item)
to catch that possibility.
| | |
155 | 162 | SUGGEST | If I understand it properly:
� :count: a number or a range equaling (or including) the num-
ber of children that match
would read more clearly as:
� :count: a number (or a range) equaling (or including) the num-
ber of children that match
| 2005-12-20 | |
150 | 157 | DEFER | I was having problems getting the tests described in chapter 12 to work. Specifically, once i deleted a piece of test data (test_destroy), that piece if data (the first book) wasn’t present again for subsequent tests. I believe the problem is that MySQL was defaulting to MyISAM format for my tables. MyISAM doesn’t support transaction rollback. It appears the way that the test harness ensures test data is in it’s original form for each test is to use a transaction ROLLBACK which is ignored by MySQL for tables using MyISAM format.
In order to fix this, I went into my create.sql script and added TYPE = InnoDB to the end of each table create.
That causes MySQL to enforce transactions and the unit tests began to work as described in the text.
Here is an example of the exact create table syntax:
create table products (
id int not null auto_increment,
…other columns…
primary key(id)
) TYPE=InnoDB;
(Dave says: this is a change to the default Rails behaviour since the book was written.
| | |
185 | | DEFER | “See the Active Support RDoc for details.” If it has been mentioned anywhere how to do this, I missed it, and so did s search of the PDF for RDoc. Generating documentation for your own app was mentioned, though the lack of detail on that was rather disappointing to me.
| | |
84 | | OK | Modifying add_product method in Cart model to correctly reflect the quantity doesn’t work. It keeps repeating the item whenever I “add-to-cart” the same item.
I have to restart the server for this changes to take effect.
FYI I am reading the Dec 8 2005 pdf version (v3.1)
Other reader said that I have to add something to rectify this problem. What is it do ??
Thanks.
Samawi
(I can’t repeat it here—it seems to work fine. Should you get to the bottom if this, could you email me with your findings: dave at pragprog.com)
| 2005-12-20 | |
216 | | DEFER | Could you add sub-sections in Database relationship (or in large chapters in general) so it’ll be easier to navigate to a specific sub-chapter in the index view (in Apple Viewer for example).
Thanks for this one great book.
| | |
140 | | DEFER | In Rails 1.0 the defaults behaviour for fixtures in tests changed. If you use MySQL without transactions (as you will if you follow the book), the fixtures are not restored after every test method.
As a fix you can either use InnoDB tables (that have transactions) or set the config value use_transactional_fixtures=false and use_instantiated_fixtures=true in test/test_helper.rb. Then you have the pre-1.0 behaviour.
(Dave says: yes, we’ll be redoing this in the next edition)
| | |
| 105 | TYPO | When I write code as in file 36:
options = [[“select a payment option”, “”]] + Order::PAYMENT_TYPES
select( “order”, “pay_type”, options)
I see an exception thrown by select. It expects the options parameter to respond to the “stringify_keys” method — which array does not respond to. When I use a Hash instead of an array it works — but unfortunately, I lose control over the ordering of the items by doing so.
| | |
| 250 | SUGGEST | I would really value an expansion on how to induce #error_message_for to format validation errors for objects that have been rolled back (by the transaction). The statement that “there’s no easy way…” is tantalizing.
| | |
191 | | DEFER | In Rails 1.0, the Inflector class correctly handles “sheep”, so the example that reads " if you have a class named Sheep, it’ll valiantly try to find a table named sheeps" is no longer true. Try “deer”, although that word will get fixed soon, too.
| | |
212 | | SUGGEST |
result = Product.update_all(“price = 1.1*price”, “title like ‘Java’”)
It would have been useful if you showed the usage of like statements when you were explaining find() too. It isn’t too hard to muck around and figure out, but would be a lot clearer if explicitly shown.
| | |
142 | | SUGGEST | Figure 12.1 suggests the members of the products hash are Product objects coming from the database, as version_control_book is. This is misleading because the products hash contains Fixtures. in particular with the former product.data_available_before_type_cast is needed in the equals assertion, whereas in the latter @product.data_available works.
| | |
| 75 | DEFER | In task A, class names in HTML are in CamelCase, like ListLine, ListTitle (p. 69).
In task B, class names in HTML are in lower case, like catalogentry, catalogprice (p. 75)
It would be better to stick to one style.
| | |
57 | | OK | For all of the people having the “No rhtml, rxml, or delegate template found for admin/_form” error, I ran “gem install rails” and that fixed it. For some reason, it wasn’t creating the admin/_from.rhtml file. I had started from a fresh Gentoo install, and used “emerge rails” to install it the first time.
| 2006-01-17 | |
51 | | DEFER | Having the table definition using the equivalent Active Record Migrations definition would be nice. In this example I’ve substituted float for decimal in the definition since migrations does not have a corresponding type.
class CreateProductsTable < ActiveRecord::Migration
def self.up
create_table :products |table|
table.column :title, :string, :limit => 100
table.column :description, :text
table.column :image_url, :string, :limit => 200
table.column :price, :decimal
\t
end
def self.down
drop_table :products
end
end
| | |
301 | | ERROR | If a section header is the first thing on a page, the link from the TOC will land on the page previous to the start of the section.
Also, the page numbering in the PDF is off - the number on the page says 292 but Adobe Reader or Preview (Mac OS X) report the page as 301. You should adjust the physical numbering and logical numbering so they are in sync. I don’t know what you are using to prepare the PDF, but you can fix page numbers using the Adobe Acrobat tool.
| | |
| 147 | ERROR | test_helper.rb must be updated in order for the test_destroy method to be used if the MySQL database is using MyISAM tables (the default for CocoaMySQL). One must set “self.use_transactional_fixtures = false”
| | |
| 148 | ERROR | Rails has recently, in 1.0, updated the way it handles fixtures. If you’re having problems, see Mike Clark’s weblog here: http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting
| | |
67 | | DEFER | The hyperlink to click back to page 56 goes to page 54. The reference to material on page 56 is correct, just the location the link moves you to is incorrect.
| | |
134 | | DEFER | Not sure if this is a difference between Rails versions, but in the test_truth method of ProductTest, the book reads “assert_kind_of Product, @product” whereas my autogenerated code was “assert_kind_of Product, products(:first)” Thought it should be noted for other readers.
| | |
| 109 | ERROR | Adding the scaffold stylesheet to the store layout seems to disable any formatting from the depot stylesheet. It doesn’t seem to matter which I list first—scaffold styling always overrides (even though in html source the order does change). I’ve tried both firefox and ie. Interestingly, I looked in the download files and neither the chapter 9 nor the chapter 10 versions of the store layout files link to the scaffold stylesheet.
| | |
77 | | DEFER | Since mysql 4.0, InnoDB has become the default storage engine, and it supports foreign key. This seems to make footnote 1 on this page unnecessary.
| | |
76 | | DEFER | The equivalent Active Record Migrations definition of line_items table:
class CreateLineItemsTable < ActiveRecord::Migration
def self.up
create_table :line_items do |table|
table.column :product_id, :integer, :null => false
table.column :quantity, :integer, :default => 0, :null => false
table.column :unit_price, :decimal, :null => false
end
execute “ALTER TABLE line_items ADD CONSTRAINT fk_items_product FOREIGN KEY (product_id) REFERENCES products (id)”
end
def self.down
drop_table :line_items
end
end
| | |
306 | | SUGGEST | I’m thinking the link to the 16.8/p323 should actually be to p310 re: Session Expiry and the :session_expiry and not to page caching?
| | |
84 | | OK | I’ve also experienced the problem where changing the implementation of add_product does not take effect until after restarting the web server.
Running on:
WEBrick 1.3.1
ruby 1.8.2 (2004-12-25) [i386-mswin32]
(Dave says: cart isn’t being reloaded. You’ll need to restart after ading the model :cart line. I’ll reword this if I do a new edition)
| 2006-01-17 | |
| 108 | DEFER | Using <%= error_messages_for( :order ) %> in book while the files contain <%= error_messages_for( “order” ) %>
| | |
| 85 | DEFER | I got into a lot of trouble on page 85. I was trying to check my code out and I hadn’t read page 86 yet. On page 86 you add model :cart,:line_item.
When I was trying to check my code on page 85, the source files would not automatically reload because of the missing model declaration. This resulted in a lot of confusion and stale cookies.
I’d rewrite this to not encourage checking things until the model declarations are added.
(Dave says: yes, that’s the plan. Sorry for the earlier confusion)
| 2006-01-17 | |
| 85 | OK | The display_cart method on this page must be placed in the store controller before the private declaration line that’s already in that class definition. I may be the only person who is paying so close attention to getting the method right that I overlook this placement but doing so results in an extended (and informative) debugging session as Rails complains it has no method called “display_cart”.
| | |
266 | | TYPO | Not certain, but shouldn’t the regexp in
def normalize_credit_card_number
self.cc_number.gsub!(/-\\w/, ’’)
end
contain \\s rather than \\w? Assuming we want to strip whitespace rather than word characters.
| | |
232 | | SUGGEST | Regarding
class User < ActiveRecord::Base
has_and_belongs_to_many :articles
def read_article(article)
articles.push_with_attributes(article, :read_at => Time.now)
end
# …
end
I am missing information on how to update-or-add articles to the list. That is, how would one best go about adding the article if it didn’t exist, or just update the Time.now bit if it existed already? Haven’t been able to find the answer. More generally, at least the mention of find_on_create (which isn’t applicable here, I don’t think?) would be a nice addition (though perhaps not on this particular page).
| | |
267 | | SUGGEST | If there is no difference between created_on and created_at, nor between updated_on and updated_at, perhaps this should be stated (even more) explicitly to avoid confusion.
| | |
387 | | SUGGEST | Couldn’t the setting-up of alternating styles be replaced with the more readable ActionView::Helpers::TextHelper.cycle()?
(Dave says: yes — this wasn’t available when the book was written)
| 2006-02-17 | |
261 | | TYPO | validates_format_of: syntax coloring error in example code; “in” should be blue instead of red
| | |
392 | | ERROR | If you download File 202 (update_many.rhtml), be aware that this file is actually generating Javascript, not HTML; therefore, the embedded HTML comment causes an error when it is executed as Javascript by the browser. Solution: delete the comment, or use Javascript-style commenting
| | |
236 | | TYPO | The section on counters states: “How many lines items does this order have?” but then the counter is created with the product, so instead it answers “How many lines items does the product have”, which doesn’t make any sense. Unless I’m completely missing something, of course…
| | |
| 375 | ERROR | render_component passing the controller as a symbol generates a camelize error with rails 1.0. Various irc members also mentioned that it is a big no-no and should be passed as render_component :controller => ‘name, :action => ’actionname’
| | |
183 | | ERROR | Grouping controllers in modules: I have grouped controllers as described in this section using the command format:
myapp> ruby script/generate controller Admin::Book action1 action2 …
FIles and directories were generated as described, however, a request formatted according to your example:
http://my.app/admin/book/edit/1234
results in an error “no action corresponds to book”.
| | |
141 | 68 | SUGGEST | As a side bar it would have been nice to have been warned about strftime and how our database with empty or default 0000-00-00 00:00:00 values for date_available would cause the application to fail.
I’m new to ROR and Ruby so, sorry if this is a known / given.
| | |
| 57 | SUGGEST | The ‘gotcha’ notes (3,4,& 5) are useful. You might consider adding another…
If you get Routing Error: Recognition failed for ‘/admin’, make sure that you’re starting WEBrick from the depot folder and not the demo folder.
| | |
| 404 | ERROR | Fading out the random three elements does not work with the File 202 (update_many.rhtml) as downloaded. Nothing happens until you remove the comments that have been inserted at the top of that file. It seems the comments affect what is returned by the “eval(request.responseText)” call.
I am using Rails 1.0.0 and Ruby 1.8.2
| | |
| 464 | ERROR | I don’t know if this is a problem with Rails 1.0, Ruby 1.8.4, or something else entirely, but I could not get the rescue_action_in_public to load properly until I changed it. Ruby kept complaining that UnknownAction was an uninitialized constant. At first I just removed it, but that was unsatisfactory.
In the end I had to change the case to use exception.class.name rather than exception, and list string constants instead of the actual class literals. Doing that made it work.
I’m completely baffled about why this may be, but I’m a Ruby newbie as well as a Rails newcomer.
| | |
| 73 | OK | In File 71 (app/view/store/index.rhtml), line 8 has an h after the “<%=”. The application works fine either way, so I am wondering if this was intentional and is a feature I don’t understand or if it is a typo.
(Dave says:" it’s the HTML escape, explained earler)
| 2006-01-17 | |
116 | | ERROR | The code given for the ship method should not include the check (if count > 0) if you want to be able to show the intended message “No orders marked as shipped” flash message when no items are checked off before submitting the form.
| | |
213 | 222 | SUGGEST | In the bit about save vs. save! when it comes to callbacks in there too it doesn’t work exactly like that either :-( Went digging and found http://dev.rubyonrails.org/ticket/1861 where they talk about it some more.
| | |
| 302 | ERROR | Shouldn’t the OrderController class extend ApplicationController or ActionController… not ActiveRecord::Base?
| | |
| Chapter 6 | OK | New to web development and DB in general. I could not get the first part of the application to connect to the DB even though all settings (UN/PW) were all correct. I was using MYSQL 5.0. I downgraded to 4.1.16 and I installed ODBC drivers (I don’t recall if that was mentioned in the book though). After I did this I could connect ok, but Only after I unistalled MySQL 5.0 first then installed ODBC and then installed MySQL 4.1.16 and recreated the DBs and tables. If the book does not mention it you should recommend the ODBC drivers installation prior to the DB, and that the user may want to stay with MySQL 4.1.X instead of 5
(Dave says: I think the ODBC issue is a red herring: Rails uses Mysql directly. I’ve also never had problems with Mysql 5: it “just worked” for me here)
| 2006-01-25 | |
300 | | DEFER | Minor! “Cookies and Sessions” in the PDF’s table of contents points to the bottom of page 300. The section actually begins at the top of page 301.
| | |
| 369 | ERROR | “If the current request is being handled by a controller called store, Rails will by default look for a layout called store_layout (with the usual .rhtml or .rxml extension) in the app/views/layouts directory”
This does not work for me. I have to add a directive like this:
layout “store_layout”
in the store_controller.rb file to get the layout to work. Am I doing something wrong, or is the default layout name different from what the book says?
| | |
71 | | SUGGEST | This is the first time depot.css is mentioned. It has to be included in the project for proper view display. Needs to be copied from the sample code.
| | |
209 | | SUGGEST | To be a little more consistent, I think the line
order = Order.find_all_by_email(params[‘email’])
should be “orders = …. ” to match the other find_all examples.
| | |
163 | | OK | The author enters several assertions before ever trying to run the test. As this section is on TDD, it might be better to get the test to pass at the assertion of the flash. Then add the next assertion. The reader would get a better feel of the flow of tdd (write a little bit of test, see it fail, write a bit of code to make it pass, see the test pass, refactor, repeat).
(Dave says: I believe this is a confusion between Test First Development and Test Driven Development. TDD doesn’t require tests to be written first)
| 2006-02-17 | |
51 | | SUGGEST | you might want to add “-u dave” to the mysql statement
| | |
438 | | ERROR | The “File Uploads” bookmark incorrectly points to the page previous to the actul “File Uploads” section.
| | |
98 | | SUGGEST | render_partial “form”
is now
render :partial => “form”
| | |
134 | | ERROR | It seems that the generator for unit tests no longer generates the setup method (Rails 1.0.0) so the code in the PDF/Book doesn’t match watch is actually produced.
| | |
146 | | ERROR | test_helper.rb looks (mostly) nothing like the example in the PDF.
It now looks like:
ENV[“RAILS_ENV”] = “test”
require File.expand_path(File.dirname(FILE) + “/../config/environment”)
require ‘test_help’
class Test::Unit::TestCase
# Transactional fixtures accelerate your tests by wrapping each test method
# in a transaction that’s rolled back on completion. This ensures that the
# test database remains unchanged so your fixtures don’t have to be reloaded
# between every test method. Fewer database queries means faster tests.
#
# Read Mike Clark’s excellent walkthrough at
# http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting
#
# Every Active Record database supports transactions except MyISAM tables
# in MySQL. Turn off transactional fixtures in this case; however, if you
# don’t care one way or the other, switching from MyISAM to InnoDB tables
# is recommended.
self.use_transactional_fixtures = false
# Instantiated fixtures are slow, but give you david where otherwise you
# would need people(:david). If you don't want to migrate your existing
# test cases which use the david style and don’t mind the speed hit (each
# instantiated fixtures translates to a database query per test method),
# then set this back to true.
self.use_instantiated_fixtures = true
# Add more helper methods to be used by all tests here…
end
| | |
261 | | ERROR | I couldn’t work out really quickly how to make a test case work to see if this is true or not, but it seems like the default message for validates_exclusion_of should be “is included in the list.” instead of “is NOT included in the list.” It doesn’t make sense to me that the default message for validates_exclusion_of and validates_inclusion_of should be the same.
| | |
| 148 | ERROR | The products and version_control_book instance variables are not available unless you set the ‘use_instantiated_fixtures’ attribute to true. This can be set in the TestCase class Rails creates for you.
| | |
34 | | OK | I’m confused by the first existing erratum above (Item #4 in the list), as I don’t understand what it refers to.
| 2006-02-17 | |
156 - 159 | | ERROR | The file examples for store_controller.rb thoughout this section contain arguments to the fixture() method that look like this.
fixtures :products, :orders.
Having both these fixtures referenced causes ActiveRecord::StatementInvalid: Mysql::Error: type errors to be raised when the test is run.
This appears to be the result of the fact that orders.yml at this point has not been modified, and contains the default generated values that Rails provides. The errors specifically mention that the orders table does not specify default values that the ActiveRecord tries to insert into this table using such assign statements as assert_equal 1, assigns(:items).size.
The addition of the necessary fixture information to oreders.yml is discussed at the end of this section, and unless I’m mistaken, has not been suggested before this.
Perhaps this will help others to trace this problem without wasting much time.
| | |
6 | | TYPO | “This book documents Rails V1.0, which became available in mid 2005” should be “This book documents Rails 1.0, which became available on December 13, 2005”
Also “the last release before Rails 1.0” should be “one of the last releases before Rails 1.0”
| | |
76 | | ERROR | As was previously stated, " In the implementaion of find_cart, the 3rd line reads “session[:cart] ||=Cart.new” This line should read “@cart = session[:cart] ||= Cart.new” " I ran into an issue in which if I accessed /store or /store/display_cart directly in a fresh (meaning session cookie-less) browser window, I could refresh the page as many times as I want and keep the same session, however if I added an item to the cart or otherwise changed pages in the browser, it would set a new cookie everytime (even everytime I refreshed the new page). Making the change noted in the quote above fixed the issue. I’m running Ruby 1.8.2, Rails 1.0.0 on a Win XP Pro SP2 pc, and I caught the error by adding the line <%= debug session %> to both my index.rhtml and display_cart.rhtml (in store views).
| | |
| 68 | DEFER | Another problem with web development is keeping HTML formating separated from its content. (The idealization of this concept is the ‘semantic web’.) It’s easy today to separate content from formatting using CSS. Most modern browsers support CSS1 and CSS2, and the CSS3 standard is around the corner. The use of CSS is an overdue concept that I would expect a book on new technologies such as this one would promote.
I am disappointed to see that the list.rhtml example on page 68 shows formatting attributes placed inline with the HTML. The attributes “cellpadding”, “cellspacing”, “width”, “height”, etc. have their CSS equivalents and could as easily been placed in the scaffold.css file. Doing so would be an added benefit for the readers of your book and for the future of the web.
I hope this gets corrected in future copies. I want to believe that such a timely and otherwise well written book is promoting all of the modern standards.
Thank you,
Jose Hales-Garcia
UCLA Department of Statistics
| | |
393 | | TYPO | It uses a trvial partial template for each line.
“trivial”
| | |
394 | | TYPO | "We’ll put these in a
|