’
irb(main):023:0> Product.select(:select => “id, title”)
(Object doesn’t support #inspect)
=>
In the second paragraph after the heading “What We Just Did”, first sentence, you have repeated the word “to” after the word “Resource”. it should read, “Finally, we used Active Resource to break free …”.
2010-10-04 247ERRORThe code change to display the error header should be wrapped in an
block. This will continue to display it with white text on a red background (as shown in the picture on the following page).
<%= t(‘errors.template.header’, :count=>@order.errors.size,
:model=>t(‘activerecord.models.order’)) %>:
“And that is all there is too it!”
should be:
“And that is all there is to it!”
2010-10-03 160SUGGESTAbout rails supporting RJS… I think this section should be re-written in the way how rails 3.0 supports unobtrusive javascript and give examples of both using prototype and jQuery. RJS is still suppoorted but considered legacy now.
2010-10-03Part II documents what is included when you install Rails, Part III covers alternatives. \n \nWhile I am a fan of JQuery, at the present time RJS is included in the core, and JQuery is something that needs to be installed separately. 105OKShouldn’t the bracket for the code come before the figure 7.1?
2010-11-10Duplicate of 44992 253OKIn the “Joe Asks…” Box, it says that the “techniques described in this chapter can be used by those developing on
Windows and deploying to Linux or Mac OSX.” I don’t believe that there is a Windows port of Passenger.
An extra period precedes the footnote 6 marker:
“… we created a new application stylesheet, depot.css, and put it in the same directory.6.”
2010-10-03 169SUGGESTYou might want to explain what xhr stands for, might not be apparent at first.
2010-11-10 232OKIn the code listing:
<%= t(‘errors.template.header’, :count=>@order.errors.size, :model=>t(‘activerecord.models.order’)) %>
should instead be:
<%= t(‘activerecord.errors.template.header’, :count=>@order.errors.size, :model=>t(‘activerecord.models.order’)) %>
2010-11-13 30TYPONow it’s Rails final, not beta, and “gem install rails”
2010-10-03 191TYPOShould probably mention or use ~> when adding to gemfile
2010-11-12 91ERRORMy generate scaffold command also had the lines
invoke stylesheets
create public/stylesheets/scaffold.css
at the end
(we’ll tart it up in a minute)
2010-10-03 151TYPO“Create a migration that copies the product price into the line item, and add_product method in the Cart model to capture the price whenever a new line item is created.”
The add_product method is there already, so it should read “Create a migration … and change the add_product method …”
2010-10-03 174SUGGESTThere are 5 bullets at the top of the page, two of which end with ‘and’ and the rest that don’t. It just seems a little inconsistent that some do and some don’t connect to the next bullet.
2010-10-03 204SUGGESTIt would be nice if you point to the lines of code that are supposed to be edited on notifier_test.rb
2010-11-12 42SUGGEST“You can force Rails to use WEBrick by providing
an option to the following command:”
should read
“You can force Rails to use WEBrick by providing
an option, like in the following command:”
or
“You can force Rails to use WEBrick by providing
an option to the rails command:”
“[2009-09-29 10:53:40] INFO WEBrick::HTTPServer#start: pid=6044 port=3000”
has all the text after the # in green, like a Ruby comment, but it’s not a Ruby comment
2010-11-10 208ERRORThe functional test will fail if you don’t provide more specific instructions. Readers will get something similar to the following:
1) Failure:
test_buying_a_product(UserStoriesTest) [/test/integration/user_stories_test.rb:48]:
<“Sam Ruby <depot@example.com>”> expected but was
<“depot@example.com”>.
1) Failure:
test_buying_a_product(UserStoriesTest) [/test/integration/user_stories_test.rb:48]:
<“Sam Ruby <depot@example.com>”> expected but was
<“readername@domain.com”>.
The error is generated because the email address provided on notifier.rb (from page 199 and 200) doesn’t match the email address provided in the test. Also, if the reader enters only depot@example.com at the notifier.rb file, the test will also fail because it has to match exactly what’s on the test, that is, Sam Ruby <depot@example.com>
It might get even more confusing if the reader substitutes depot@example.com for their own email address.
I think this section needs to be addressed with more specific instructions.
2010-11-12 358OKHello,
I am not sure that it is a bug in Rails 3 or not.
I just came back to Rails after a long break and I was refreshing my memory about before_filter.
You write in the book that the original action doesn’t run if the filter returns false or renders or redirect. This supposed to be as you say (based on google results) but based on my tests it is not.
class ClubsController < ApplicationController
before_filter :test
def index
logger.info ’ —- * index* —-’
@clubs = Club.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @clubs }
end
end
protected
def test
logger.info ‘—- * filter* —-’
render text: ‘text’
return false
end
end
Log output for this:
Started GET “/clubs” for 127.0.0.1 at 2010-09-17 02:28:25 +0200
Processing by ClubsController#index as HTML
—- * filter* —-
Rendered text template (0.0ms)
Completed 200 OK in 13ms (Views: 13.0ms | ActiveRecord: 0.0ms)
Which is fine.
Now I remove the render text: line from the filter method.
The log putput will look like:
Started GET “/clubs” for 127.0.0.1 at 2010-09-17 02:27:23 +0200
Processing by ClubsController#index as HTML
—- * filter* —-
—- * index* —-
Club Load (0.0ms) SELECT “clubs”.* FROM “clubs”
Rendered clubs/index.html.erb within layouts/application (3.0ms)
Completed 200 OK in 17ms (Views: 6.0ms | ActiveRecord: 0.0ms)
As you see ‘return false’ simply didn’t stop the action. Is this a bug or a new feature in Rails 3?
I am using Gentoo, rvm, ruby 1.9.2, rails 3.0.0
Mage
2010-11-13Please report this to the Rails developers 179OKPerhaps I missed a step somewhere, but I received the error that line_items is not a function for nil class when cart.line_items.empty? is called in application.html.erb after the Checkout button is clicked. I added
cart = current_cart in new method in the Orders controller to resolve the problem. Again, maybe I missed a step.
In the source code of the “first attempt” to hide the cart, this render command is used:
<%= render(:partial => “cart”, :object => cart) %>
It raises an exception. Instead <%= render(
cart) %> should be used, as in the code snippets before and after this one.
for the listing in the example file for line_items.yml, it has product: ruby, cart: one
for my generated version it has:
product_id = 1, and cart_id = 1.
I had thought I followed the instructions to the letter, not sure if I messed something up with my rake commands.
ruby 1.8.7 (2010-01-10 patchlevel 249) [i486-linux]
gem 1.3.7
Rails 3.0.0
on ubuntu 10.04 32
“Finding the cart at the start of each action is starting to get tedious; we’ll see how to remove this duplication later.”
A reference to a later page should be inserted here.
The second Play Time exercise doesn’t make sense to me: Since cart is not set in the orders_controller, the cart disappears from the sidebar as soon as the checkout process is started. Therefore the checkout button cannot be clicked again during checkout. The most simple solution would be to add "
cart = current_cart" to the “new” action on page 175.
The sample code for depot_s/app/views/users/index.html.erb
You should add an if statement before the notice paragraph, because if this is not done, there is a permanent gray rectangle with a red border on the users administration page.
2010-11-13 240ERRORes.yml
should be add_html: instead of just add:
index.html.erb
should be button_to t(‘.add_HTML’ instead of button_to t(‘.add’
The order_shipped method in notifier.rb has not been altered and thus does not expect an “order” parameter, making test_order_shipped fail.
2010-11-12 204TYPOThe ‘from’ address in the tests should be ‘from@example.com’ as used in notifier.rb above, instead of ‘depot@example.com’.
2010-11-12 209TYPO“Without much code, and a few templates” sounds strange, should be e.g. “Without much code, and with just a few templates”
2010-10-03 23TYPOMissing “the”: “surveys entire Rails ecosystem” should read “surveys the entire Rails ecosystem”
2010-11-10 228TYPO“adding a links”
2010-10-03 233TYPO“have to changes” should read “have to change”
2010-10-03 95SUGGESTAt the bottom of page 95, we have “(And three commands…”, and the top of page 96 we have “…with only four commands.”
2010-10-03 190OKI can’t get the atom feed to work, and I’m not seeing any error messages either. I simply get nothing. Including some information about how to deal with errors for a new format responder would be much appreciated.
2010-11-12 155TYPO“That means that we need to name our partial
_line_item.html.erb and place it the app/views/line_items directory” misses an ‘in’
-> “That means that we need to name our partial
_line_item.html.erb and place it in the app/views/line_items directory”
Top paragraph “we already call the error_messages_for helper…”. I believe that code was removed.
2010-11-10 188OKTask G download code references seem to be a bit off. References in the book move back and forth between depot_o and depot_p, and the actual dowload source code is sometimes out of sync with the book text.
2010-11-12 193OK“The default is to show 30 entries per page,” should be: “The default is to show 10 entries per page,”
2010-10-03 60ERRORClass Order lacks the discount property
require ‘active_record’
class Order < ActiveRecord::Base
end
order = Order.find(1)
order.discount = 0.5
order.save
This page mentions the h method, but I can’t find any reference to it anywhere else in the book. It’s not in the index either, nor is html_escape. I assume that this is related to the introduction of SafeBuffers in Rails 3 which maybe eliminates the need for h(), but the dangling reference here is rather cryptic.
2010-10-04 287TYPOYou have the word “on” twice. “Configuring Rails Applications guide you generated with the rails doc:guides command on on page 281”.
2010-10-03 302TYPOYou have “is” twice: “This is is useful for doing things like storing values from HTML forms into database rows.”
2010-10-03 307TYPOMistyped “placeholders” as “placeholderis”.
“We do that by placing placeholderis of the form :name into the string, and by providing corresponding values in a hash…”
2010-10-03 168TYPO“we point our browser to http ://localhost/products/.” should be “we point our browser to http ://localhost:3000/products/.”
(both times without the white space in the URL)
2010-10-03 336TYPOThe second sentence of the paragraph after the Adding Additional Actions subtitle reads “on page 187 we added an create an interface to allow people to fetch a list of people who bought any given product.”
It reads awkwardly because of the two “an”: “we added an create an interface”
2010-10-04 217ERRORapp/views/users/index.html.erb needs notice code:
<% if notice %>
<%= notice %>
<% end %>
2010-11-12 423OKThe URL provided in the footnote does not link to a page that describes a plugin for fkey migration helpers.
2010-11-14 369OKIn the table at the bottom of the page, under the params column, you have an opening single quote and a closing double quote { :id => ’123" }
Maybe you meant to have either 2 single or 2 double quotes instead.
2010-10-04Both are double quotes 131TYPOIn the last section of code (product.rb), The second line:
has_many :line_items
is missing the small triangle indicating it is the added line of code.
In your screenshot of the sidebar cart you have the dark green background of the sidebar extend to cover the entire area behind the cart. I’m pretty sure I followed your instructions exactly and my cart overruns the dark green background. I tested both on Google Chrome and Mozilla Firefox. I apologize if this is user error.
2010-11-12 179TYPOYou flag the PAYMENT_TYPES line as a new line in order.rb (with that yellow arrow), but you had us add it just the page before. Yellow flag should probably be removed.
2010-11-10 434SUGGESTIn the sentence just below the figure, are you sure you want to say “sophistically advanced”? The word “sophistic” means “plausible but fallacious”…
2010-10-04 279TYPOSentence " For example, if we generate my_app using the command rails new my_app, the top-level directory for our new application is shown in Figure 18.1, on page 281.." has two periods at end.
2010-10-05 134TYPOI just bought pdf version and having some problem to understand.
line_item =
cart.line_items.build(:product => product)
why we have :product=> product
line_items has :product_id not :product?
I can’t get it.
Please email me somebody to ulugbekov@hotmail.com
Thanks in advance
InSection 12.2, IterationG2:Atom Feeds,on page 187 we added
an create an interface to allow people to fetch a list of people who bought any given product.
Should be we added and created an interface
2010-11-13 105TYPOFigure 7.1 does not show a validation error even though the price is less than 0.01. My code did the same thing until I caught a typo in it (though the code in the book looks correct)
2010-11-14 343TYPOBottom of the pdf
such as htmlatom or js;
should be
such as html atom or js;
At the end of 12.1, you say “Now that we’ve captured the order it is time to alert the ordering department. We will do that with feeds. Specifically, an Atom formatted feed of orders.”
But that’s not what we do next, instead we create an Atom feed of who’s ordered a specific book, which is something of a leap.
2010-11-12 179TYPOIn the code listing for the Gemfile where we add will_paginate, the #START_HIGHLIGHT and #END_HIGHLIGHT comments are being displayed instead of highlighting the right line
2010-10-18 187TYPO“The generate script created two e-mail templates in app/views/order_mailer, one
for each action in the OrderMailer class.”
No it didn’t, it created two e-mail templates in app/views/notifier, one for each action in the Notifier class.
2010-10-18 149OKThe RJS templates are now legacy with Rails 3.0. Could you please update this section with unobtrusive JS examples
?
In the following paragraph:
“We start by introducing you to a number of such dependencies, starting with the underlying templating engines that power views. Then we will do a explore
bundler which is the component that is used to manage dependencies. Finally, we will show how these pieces are put together using rack and rake.”
The sentence:
“Then we will do a explore bundler which is the component that is used to manage dependencies”
Should probably be:
“Then we will explore bundler which is the component that is used to manage dependencies”
“do a” has been removed.
2010-10-18 250TYPOThe comment ’# optional task to reconfigure databases" should be probably above the task :seed
2010-10-18 276OKAt the top of the page is a table which consists of “Class Name”, “Table Name”, “Class Name”, “Table Name”. The first set of headers is normal, but the second set is bold.
Also, it says “These rules reflect DHH’s philosophy”, but up until now it’s been described as Rails’ philosophy.
2010-11-13 385TYPOThe code sample here contains:
#START_HIGHLIGHT
create db/migrate/20100301000010_create_discounts.rb
#END_HIGHLIGHT
rather than highlighting the right line.
2010-10-18 28OKArguably homebrew (mxcl.github.com/homebrew/) is a better option for installing SQLite 3, MacPorts has several drawbacks. Additionally, more and more people are using rvm (rvm.beginrescueend.com) for installing ruby. Then I think that is worth to mention this as the preferred path rather than MacPorts
2010-11-10MacPorts is what I am comfortable with 34TYPO“sup-ports” rather than “supports”
2011-02-26 54TYPO#
#
Cannot find ‘gem ruby 3.0.1.pre’
Ref: Download depot_q/Gemfile; 12.3 Iteration G3: Pagination
Continuing through your Pragmatic Bookstore application comes to a halt without this gem.
2010-11-03 153SUGGESTAre the and comments supposed to be there? I don’t seem to recall those being in the previous beta versions of the book.
2010-10-18 106OKWhen I enter characters in the Price field I get the ‘Price is not a number’ message as expected but the price value gets changed to 0.0 as well. (I’m running Rails 3.0)
2010-11-10 1354OKIn the sample code of the “Generating the Scaffold” section of the depot example, there is a “\\” following Product that should be removed.
This is the .mobi location 1354-66
2010-10-18See footnote on this page 358TYPOThe popup parameter to link_to no longer works in Rails 3. I tried to link to a discussion of this but your spam police wouldn’t let me.
2010-11-13 149OKIn the carts/show.html.erb another change has snuck in that isn’t immediately obvious - namely the change from h2 tags to a div with the class of ‘cart_title’. (I actually only noticed this in the next chapter when creating the cart partial.) Astute readers who make the change here will see a yucky display of the cart title because the style sheet on the next page hasn’t got a style for ‘cart_title’. I suggest you just change the div back to an h2 and then highlight the change from the h2 to the div in the next chapter.
2010-11-10 158SUGGESTAfter first moving the cart to the side-bar the formatting of the side-bar is pretty cactus - certainly not at all as it appears in Figure 11.1. Am I right in assuming you’ve changed the side width and main margin values? If so, please reflect that in the style-sheet changes and download on the previous page. (I seem to remember this caused me grief when I first worked through it in the second or third edition of the book.)
2010-11-12 243OKWhen moving the app to Ubuntu 10.04, in the second bullet point, I found I needed “RackEnv development” rather than “RailsEnv development” to change the database used. The explanation I found is that the config.ru file indicates that Passenger should treat the app as a Rack application as opposed to a rails application.
I also found that in Ubuntu, I didn’t have the will_paginate gem. I used a (probably inefficient) combination of sudo gem install and sudo gem update to fix this.
2010-11-13 373SUGGESTAttachment FU is a bit of a workaround (requires dependencies, a litle messy) - what are the chances of including a solution such as Paperclip in here?
Uploading images is such a core feature, I think it deserves a multiple solution approach. I understand that using plugins should be minimised - but such a core feature should have a simple solution documented.
2010-11-13 355TYPOI am no expert… but shouldn’t these lines be using => instead of =<?
<%= number_with_delimiter(12345678, :delimiter =< “_”) %>
12_345_678
<%= number_with_precision(50.0/3, :precision =< 2) %>
16.67
Where you say “And that’s it.”, it’s not quite. You’ve missed the email check - although you’ve included it in the full code listing. I suggest discussing it explicitly before the full code listing.
2010-10-18 208OKThis one fails:
assert_equal ‘Sam Ruby <depot@example.com>’, mail[:from].value
It should be:
assert_equal ‘<depot@example.com>’, mail[:from].value
Oops! Ignore the previous error. It should have said:
This one fails:
assert_equal ‘Sam Ruby <depot@example.com>’, mail[:from].value
It should be:
assert_equal ‘depot@example.com’, mail[:from].value
The CartsController skip_before_filter call should specify :destroy rather than :delete.
2010-10-18 240ERRORThe Add to cart button in Spanish does not appear with the correct characters. t(‘.add’) should be t(‘.add_html’) and the YAML files should be changed as well.
2010-11-13 247ERRORYou need to insert the following before the ul element if you want the ‘body’ message to appear as shown in the figure:
<%= t(‘errors.template.body’) %>
2010-11-13 14SUGGESTNot sure what this is supposed to mean: “Rails also works on Ruby 1.9, though some of the examples had to be modified in order for this to work.”
What examples? The examples that come with Rails? The examples in this book? Should it say “… in order to work” instead of “in order for this to work”?
2010-10-18 96OKThe code snippet at the bottom of page 95 is missing a bracket, which appears under the screen shot on page 96. So if you do a copy and paste of the code, you get an error because the bracket gets left out.
2010-11-10Duplicate of 44992 181SUGGESTAfter adding Pagination in the Gemfile, and issuing the “bundle” command, I found I needed to stop and start the rails server for it to take effect. (Mac OS, Rails 3.0, Pagination 3.0.pre2, Ruby 1.8). If this is required, that would be a good add, because this is the first time I HAD to do that.
2010-10-18 258TYPOThe sentence “While conventions keep to a minimum the amount of configuration required
for a Rails application, we did do a bit customization” should read “did do a bit of customization.”
Once you have changed the routes to use a locale, the user_stories_test integration stops working because some of the routes no longer work as they are written in the test. For example, the xml_http_request test:
xml_http_request :post, ‘/line_items’, :product_id => ruby_book.id
Must now go to /en/line_items (or you can insert the locale some other way) or else the line item is not created.
I think you need the word “or” in “either to create Rails
Metal applications, to use Rack Middlewares in your Rails application” inbetween the comma and the ‘to’.
Minor nit: Figure 2.3 has "
" in the HEAD, but the browser screenshot immediately below it shows “Demo1” in the window’s titlebar.
2010-11-14Duplicate of #44285 55TYPOshould say “modify the pay type”, not “modify the discount”.
2010-10-27 217ERRORin the playtime section, there’s no need to modify the update function to accept confirmed password instead of a hashed password and a salt, it already accepts because of the shared partial.
2010-11-12 134TYPOThe reference to the logger in the last paragraph points to the wrong page.
2010-11-10 280ERRORThere’s mention of a “Parts” class that was supposedly done in the depot application, but I don’t recall that actually being there.
2010-10-27 95OKBased on the unit test created for this function later in the chapter, the validator for images should be case-insensitive.
Therefore, the image validator should read (added the “i” modifier immediately after the regex literal):
validates :image_url, :format => {
:with => %r{\\.(gif|jpg|png)$}i,
:message => ‘must be a URL for GIF, JPG or PNG image.’
}
I realize this chapter on Ruby can’t be thorough and you do a good job making that clear. However, speaking as a Rails AND Ruby newb, I can say that the too-brief section on blocks and “yield” isn’t working for me. You explain “yield” just a bit, but there are no example usages in the text. It’s implied in the iterator/block combinations but it needs to be explicit in order to be pedagogically useful. Otherwise, please consider adding a direct reference to some other resource that explains it more fully.
2010-11-10 310ERRORThe summary claims that have used ActiveRecord outside the context of Rails, but I don’t think that section is in this chapter anymore/yet?
2010-10-27 314OKWhen I do a rake routes, all of the routes seem to have a name for me, not just the four with names shown here. Is this due to my setup being different (I did some of the extra exercises)?
2010-11-13Context here is "Let’s take a look at how the config/routes.rb might have \n looked back in Section 6.1, Creating a Rails Application, on page 80. \n" 322OKassert_generates, assert_recognizes, and assert_routing all seem to be pretty similar in terms of what they test - do you think you could give some information or best practices about which you should use and when? That would help make this a lot clearer.
2010-11-13Assert routing is a convenience that combines both of the other APIs. 115ERROR(It didn’t seem possible to report an erratum against the index so I reported it against this section on functional testing.)
In the index under Functional tests, it says “see also Test”, but when I look under Test, there is no mention of functional testing.
2010-12-21 347TYPO“Rails is ready even if the browser your users have installed are not” should use “is” and not “are” for the last verb, as “browser” is singular.
2010-10-27 348TYPONo comma is needed after the number 39 in “Finally, lines 39, and 44”.
2010-10-27 01OKWhy not adding a chapter introducing Passenger 3 with its beautiful Passenger Lite that is much much better than WebBrick?
2010-10-27Passenger is covered in chapter 16. Before that point the focus on the book is documenting Rails as you get it by default. Additionally, a good portion of the readers are on Windows. 126OK“tart” should be “start”
For now, lets write a trivial template (we’ll tart it up in a minute):
In the second bullet point “The first time through” should presumably be “The first time though”.
2010-10-27 128TYPOHint: the pluralize helper (described on page 353)
should be page 356 in the pdf
“The first thing you should notice is that the file is considerably more smaller.”
should be changed to
“The first thing you should notice is that the file is considerably smaller.”
2010-11-14 438TYPO“By downloading one script and adding one few lines of javascript…”
should be
“By downloading one script and adding a few lines of javascript…”
2010-11-14 431TYPO“We won’t be using the sever in this section”
should be changed to
“We won’t be using the server in this section”
“using the sever in this section” should be “server”
2010-11-14 435SUGGEST“dots and pound signs…”. I know you mean #. Wikipedia defines pound sign as £. Most europeans probably think of £, certainly brits. Music lovers call a # a sharp, most programmers seem to call it a hash symbol.
2010-11-14 309SUGGESTIn “Built-in Transactions” sections after words “When we discussed parent and child tables…”, a reference to Page 282 (“One-to-Many Relationships”) would be very helpful.
2010-11-13 294TYPOIn the very beginning of section “Writing Our Own SQL”, it feels like a missing word where marked below:
The methods we have been looking at each contribute to the construction…
2010-11-13 314TYPOIn sentence “The resources line caused seven new routes to be added our application.” — missing “to”, should read “… to be added to our application.”
2010-11-13 397TYPOI might just be dense or reading something incorrectly, but there are many references on p397 to ‘options’ set in the example depot_r/db/migrate/20100301000003_create_line_items.rb, such as “If you look at the line item migration in the preceding section, you might wonder
about the duplication between the two option parameters”, but I do not see any options parameters nor understand what it is talking about
The pictures do not show up on our products index page. I did download the pictures and place them in public/images diretory, but no dice. While tailing the develoment log, I get a routing error.
ActionController::RoutingError (No route matches “/images/ruby.jpg”):
In Rails 3 there is no support for actionwebservice and it would be nice to be described in book how to make simple Web services in Rails 3. Just some basic stuff.
2010-11-10SOAP is out of scope for this book, and the book does describe how to produce XML and JSON responses. 415TYPOThird paragraph of Chapter 25 (“Rails’ Dependencies”) starts as:
While this chapter goes a beyond your normal day-to-day activities…
“goes a beyond” should be just “goes beyond”.
2010-11-14 201TYPOI don’t think that the class << self idiom has been used to this point. If the goal is to create a class method, that has been done with self.method, which should be again used here for clarity and consistency in this introductory text. In any case, if class << self is used, it’s meaning should be explained.
2010-11-12 253TYPO“Note that in this case an explicit require of active_support is that active support has not been configured yet” — check the grammar of that fragment
2010-11-13 257OKThis chapter would be great functional index for those who had read the book to come back to. The steps (like creating seed data) are all organized by function rather than alphabetically, which is great. All that is missing is the pointers to the page or section where, e.g., how to set up seed data, is discussed.
2010-11-13 368TYPOThere is a period missing after the number 434 where it says “on page 434”.
2010-11-13 378SUGGESTCould you elaborate more on how stale? and fresh_when are used and how they’re different? I’m having a really hard time following the information listed here.
2010-11-14 381SUGGESTUsing a whole page for this picture seems really excessive, I think you could make it a lot smaller.
2010-11-18 81OK> rails generate scaffold Product title:string description:text image_url:string price:decimal
Testing the application on a MySql db instead of bundled sqlite, results in a default decimal(10,0) column. Yes, we are supposed to work with sqlite in development environments, but what about moving to production? The application was created using
> rails new depot -d mysql
About Git.
I’m absolutely new to Git. What should I do to use Git?
Sign up online on something like Github? Install a package from repository? Install the Git ruby gem?
I first installed git package for ubuntu, immediately removed it for testing the Git rubygem first. In the end I figured out that i was supposed to install git package.
apt-get install git
2010-11-10sudo apt-get install git-core 307OKprice_must_be_at_least_a_cent is misnamed — it does not relate to the price (it relates to the balance) and it does not require the balance to be at least a cent (it only requires that it be non-negative)
2010-11-13 312OKPages 311 And 312 describe routing, but are not referenced in the index under Routing
2010-11-14Comment superseded by comment 45494 322TYPOActually, pages 311 - 322 are mostly about routing, and should be listed under Routing in the index
2010-12-21 396SUGGESTThis page is almost totally empty in this version. I know the final one may not be like this, but this just looks odd.
2010-11-14 397ERRORThe CreateLineItems migration example for the execute method doesn’t actually use execute…?
2010-11-14 431TYPO“we will create small script” needs to be “we will create a small script”
2010-11-14 442TYPO“We covered topic ranging from” should be “We covered topics ranging from”. “We covered migration an caching as” should be “We covered migration and caching as”.
2010-11-14 70TYPOIt should be “an”, not “a” before “object” in sentence “The lambda operator converts a block into a object of type Proc.”
2010-11-10 181OKAnd that is all there is to it! The default is to show 30 entries per page….And that is all there is to it! The default is to show 10 entries per page
2010-11-10The default is 30 183ERRORthe second question in play time doesn’t make sense to me.
once “checkout” button is clicked, the cart disapears so there is no more checkout button to click…
The cache examples use the h() function twice, on pages 380 and 382. Is it appropriate to use h() in Rails 3?
2010-11-14 431TYPOAdditionally, if you have a rails server up and running, restart it to pickup these changes.We
won’t be using the sever in this section, but will shortly.
sever should be server
2010-11-14 22TYPO“The third part of the book, starting on page 262, surveys entire Rails ecosys- tem.”
That should either end with “entire Rails ecosystems” or “the entire Rails ecosystem”.
2010-11-10 98OKTo make the functional test pass, you have to also fix the fixture? My fixture contains
one: {}
- column: value
Pages 423 & 424 also make reference to defining routing, so they should be in the index under Routing
2010-12-21 300OKThe book says that there are two ways to define callbacks, one being “directly” by overwriting the method and the other by declaring handlers. I think the first way is what is now causing deprecation errors like “DEPRECATION WARNING: Base#before_create has been deprecated, please use Base.before_create :method instead.” I could easily be wrong since I’m fairly new to Rails, but I figured I would bring it to your attention in case this method should be dropped from the book.
2010-11-13I'm not seeing these warnings. 319SUGGESTUnder “Selecting a Data Representation”, it says “… they should see a nicely formatted HTML.” A HTML? It sounds strange with the article there. Also, in the previous sentence, “human user uses” sounds a little funny.
2010-11-13 34OKbullet point NetBeans: remove hard hyphen from word “sup-ports”
2010-11-10Duplicate of 45306 45TYPObullet point 2, second paragraph: URL breaks justification
2011-02-26 56SUGGEST“will be seeing and modifying a number of controllers in the
development of the Depot application”
Has the Depot application been introduced yet? Should it read something like, “in the development of the Depot application (the sample application we’ll be building in this book”?
2010-11-10 71OKShould you introduce booleans in your introduction to ruby?
2010-11-10 63SUGGESTI think it would be useful to at least mention “unless” and “until” here.
2010-11-10 213ERRORusers also need to be able to “destroy” line items.
“lineitem#destroy” should be added to the white list too.
class LineItemsController < ApplicationController
skip_before_filter :authorize, :only => [:create, :destroy]
from my limited understanding, I suspect we should have a:
“fixtures :products ”
line a the top of the tests class to ensure that the fixtures data is correctly used. If not, then it would be a good idea to explain why not.
There’s a footnote at the bottom of page 266 that talks about the Pragmatic Programmer store, but it took me far too long to realize that you meant the actual store and not the depot application used as a running example in the book. It would be nice if this could point to a code example somewhere online of using the lib directory.
2010-11-13 57SUGGESTSecond paragraph is a run-on sentence with three independent clauses. Consider using different punctuation or breaking up into separate sentences.
2010-11-10 111OK<sanitize product.description>
should be:
<%= sanitize product.description %>
2010-11-10 111OKBy the style guidelines you gave earlier, shouldn’t:
image_tag(product.image_url)
be:
image_tag product.image_url
?
2010-11-10 29OKFresh/clean Macbook Air, the default path is not /opt:
for cmd in ruby irb gem rake; do which $cmd; done
/usr/bin/ruby
/usr/bin/irb
/usr/bin/gem
/usr/bin/rake
Time.zone = ‘Eastern Time (US & Canada)’ — should be & not &
2010-11-14 323TYPOapplication is spelled “appilcation” in the first paragraph on page 323.
… during the development of your appilcation, this is good…
2010-11-13 315OKupdate_attribute skips validation, and will save all attributes in a dirty record. It’s listed in the book next to update_attributES as if they can be easily interchanged which I think will catch some people out. For updating a single attribute I think update_attributes(:key => “value”) should be used instead.
2010-11-13 165TYPOBefore the code snippet, should be “order controller” instead of “store controller”
2010-11-10 101ERRORFor the initial unit test there are only five assertions performed and five successfully tested. The output on the page shows 6 assertions successfully tested.
2010-11-10 315ERRORMiddle of the page: text refers to “map.resource” rather than the new-style “resources”. The code example is correct, however.
2010-11-13 320ERRORMiddle of the page: text refers to “map.resources” rather than the new-style “resources”.
2010-11-13 432SUGGEST“The primary disadvantages of non-gem … gems is …” confusing.
2010-11-14 135OKIn building the rescue handler for the controller from section E2, the “store_url” does not route by default at this point. I have run “rake routes” and there is only “store_index” at this point. Changing the redirect_to “root_url” solves this problem or one has to add the routes to routes.rb.
Here is my rake routes:
mkazmier$ rake routes
(in /Users/mkazmier/rails/depot)
line_items GET /line_items(.:format) {:action=>“index”, :controller=>“line_items”}
line_items POST /line_items(.:format) {:action=>“create”, :controller=>“line_items”}
new_line_item GET /line_items/new(.:format) {:action=>“new”, :controller=>“line_items”}
edit_line_item GET /line_items/:id/edit(.:format) {:action=>“edit”, :controller=>“line_items”}
line_item GET /line_items/:id(.:format) {:action=>“show”, :controller=>“line_items”}
line_item PUT /line_items/:id(.:format) {:action=>“update”, :controller=>“line_items”}
line_item DELETE /line_items/:id(.:format) {:action=>“destroy”, :controller=>“line_items”}
carts GET /carts(.:format) {:action=>“index”, :controller=>“carts”}
carts POST /carts(.:format) {:action=>“create”, :controller=>“carts”}
new_cart GET /carts/new(.:format) {:action=>“new”, :controller=>“carts”}
edit_cart GET /carts/:id/edit(.:format) {:action=>“edit”, :controller=>“carts”}
cart GET /carts/:id(.:format) {:action=>“show”, :controller=>“carts”}
cart PUT /carts/:id(.:format) {:action=>“update”, :controller=>“carts”}
cart DELETE /carts/:id(.:format) {:action=>“destroy”, :controller=>“carts”}
store_index GET /store/index(.:format) {:action=>“index”, :controller=>“store”}
products GET /products(.:format) {:action=>“index”, :controller=>“products”}
products POST /products(.:format) {:action=>“create”, :controller=>“products”}
new_product GET /products/new(.:format) {:action=>“new”, :controller=>“products”}
edit_product GET /products/:id/edit(.:format) {:action=>“edit”, :controller=>“products”}
product GET /products/:id(.:format) {:action=>“show”, :controller=>“products”}
product PUT /products/:id(.:format) {:action=>“update”, :controller=>“products”}
product DELETE /products/:id(.:format) {:action=>“destroy”, :controller=>“products”}
root /(.:format) {:action=>“index”, :controller=>“store”}
Thanks - love your books and the beta book process!
2010-11-12On page 109 you should have added the following to config/routes: \n \nroot :to => 'store#index', :as => 'store' \n 276TYPOMisplaced possessive apostrophe in the second paragraph: “you can add to Rail’s understanding” should be “you can add to Rails’ understanding”.
2010-11-13 22SUGGESTMinor note: Triangles highlighting the changed code appear as ‘*’ (asterisks) in the ePub format, as displayed on a iOS iBooks app (iPad and iPhone 3GS tested).
2011-03-02That's correct—for portability across devices, we have to avoid Unicode in code fonts. 29SUGGESTTo help new users, clarify that the Mac OSX SQLite 3 version checker is a Ruby program, e.g.
“You can verify which version […] is bound to by running the following as a [Ruby] stand-alone program:”
hello.html.erb changes are shown as only the last 3 lines, whereas all four lines have been edited.
2010-11-13The first line was modified on page 41 105SUGGESTIn the assert_equal statement you’re using join(‘; ’). However, it is not immediately obvious why. I’m still u certain why it is required. Maybe you can add a line explaining it?
2010-11-14 126SUGGESTI believe the screenshot on this page is wrong. If the steps have been followed up to this point, a different style is used for the message (and it’s surrounded by the rest of the page).
2010-11-14 126SUGGESTTo keep with the style you’ve been using so far in the book, shouldn’t it be:
@cart.line_items.each
instead of:
for item in @cart.line_items
?
2010-11-13 121OKWould it make sense at this point to mention the security considerations involved with storing the cart id in a session like this (if cookie session store is used, users can increment the cart id in their cookie to get another users’ cart)?
2010-11-14 36SUGGEST1.7 Claims “We (optionally) selected a version control system.” This is not true, while there is a small blurb about version control on page 32, we do not select one, we are not presented with options, and we are not given any instruction on how to use Git, the one version control mentioned. This may occur later in the text, but it does not occur in chapter 1, and suggesting such left me very confused and thinking I missed a major section. I reread the Version Control section on page 32 numerous times, and I certainly do not feel that I selected a version control system.
2010-11-13 28OKIf you’re going to suggest MacPorts please provide steps for setting up and installing MacPorts.
2010-11-14The footnote on page 4 links to the installation instructions. 91ERRORseeds.rb creates the products in the order, wd4d, prog ruby 1.9, debug it
The image displayed on page 91 has the products listed in alphabetical order, or the reverse order from how they were entered into the db. There isn’t any code that was added that should have adjusted the order from how they were entered by seed.db that I could find.
2010-11-14 130SUGGESTFor style:
current_item = LineItem.new(:product_id=>product_id)
should be:
current_item = LineItem.new(:product_id => product_id)
2010-11-14 130OKFor someone learning rails, two things were unclear when changing the model here: 1) Why don’t you need to do current_item.save after updating the quantity? 2) Why do you have to append to line_items in the else case? Doesn’t .line_items look up the line items associated with the Cart on the fly?
2010-11-141) line_item.save is called in the line items controller. \n2) we need to add the new item to the list of items associated with this product. 130SUGGESTTo follow recommended Ruby style, should “for item in cart.line_items" be "
cart.line_items.each do |item|”?
For consistency, the key/value pairs in this page (3 of them) should be “key => value” not “key=>value”.
2010-11-14In this case, I'm trying to keep the line width manageable (to fit on the page). 109ERRORrm public/index.html should be git rm public/index.html if the student is using git version control as suggested earlier in the book.
2010-11-14 137OKI don’t want to spam this system so I’ll stop reporting every single one, but there are many places that use “for x in y” instead of “x.each do |y|”. It would probably make sense to standardize usage to either one or the other, unless the goal is to use both to get people comfortable with both styles.
2010-11-19 88ERRORThe contents of the downloaded depot_b/db/seeds.rb differ from the code listing on this page (“Web Design for Developers” vs. “Programming Ruby”). A small point, but might confuse the reader.
2010-11-19 88OKA Readme file in the downloaded code root directory would help guide users as to which section matches which version of the depot application.
2010-11-19 89OKThe application.html.erb code listing includes a ‘triangle’ marker to show a code change when no change has been made. This is the original unedited file.
2010-11-19 140SUGGESTExplain why .to_a is necessary here?
2010-11-19 121OKYou might want to add price to the line_items table schema here, since you mentioned on page 78 that we’re jumping the gun a little bit and adding this to our schema early. I was confused by the first playtime on page 141 because I thought price had already been added to the table based on what I read on page 78.
2010-11-19That's a playtime exercise (page 141) 147OKIf you follow these instructions after having done the playtime where you add a delete button to each line item, it looks pretty bad in the sidebar…
2010-11-19 149OKWouldn’t you want to put the “format.js” in the else block too?
2010-11-19You wouldn't want that template in the case of an error. 158TYPO“Instead of a redirect, we expect a successful response containing call to replace” should be “…containing a call…”
2010-11-19 139ERRORUnder Rails 3.0.1, Ruby 1.8.7 running on Mac OS/X 10.6.5, it appears that the redirect_to ignores the flash message when set as a :notice or :alert, and crashing when set as a :flash message, with:
undefined method `keys’ for Line item was successfully created.
The code in question is:
def create
cart = current_cart
product = Product.find(params[:product_id])
line_item = @cart.line_items.build(:product => product)
respond_to do |format|
if line_item.save
format.html { redirect_to(
line_item.cart,
:notice => ‘Line item was successfully created.’) }
I’m still working my way around RoR, but this would appear to be a bug in v3.0.1, from what I can deduce. Or have I done something wrong?
2010-11-19Can't reproduce. 204ERRORAfter clicking “Create User”, the index is redisplayed, but without the cheery flash notice. I see this has been mentioned for previous printings (B6 and B7).
2010-11-19 123ERRORerrors[:base] is not explained (where is this error shown?)
2010-11-19 160OKThe playtime things here are awfully hard to do for someone new to Rails with the tiiiiny introduction to Ajax in Rails that was given in this chapter (in contrast to the previous playtimes). I think I’ll stop doing the playtimes for the rest of the book and maybe try them after actually learning enough to do them.
2010-11-19 148OKRegarding comment #44286: I too found my AJAX implementation broken, and in the same way, down to a silly typo on my behalf. Instead of:
<%= button_to ‘Add to cart’,
line_items_path(:product_id => product),
:remote => true %>
.. I inadvertently included the :remote parameter in the line_items_path, like this:
<%= button_to ‘Add to cart’,
line_items_path(:product_id => product,
:remote => true) %>
I imagine this will be a common typo and the cause of a few frustrated debugging sessions. Perhaps a note on this would be of help?
Mind you, learnt a lot on how to troubleshoot by making these kind of mistakes… :-)
2010-11-19 165ERRORThe _form partial differs from what is created by Rails 3.0.1, so I presume you want the reader to change it accordingly, but no triangles are displayed, and the text implies that the autogenerated _form will be used.
In other words, my suggestion is to either add triangles, explain that some modifications to the default _form are required, or both. :-)
2010-11-20 165SUGGEST<%= render ‘form’ %> has the wrong indenting
2010-11-20 167SUGGESTThe line “PAYMENT_TYPES = [ ”Check“, ”Credit card“, ”Purchase order" ]" has already been added, so it doesn’t need a little arrow at the beginning of it.
2010-11-20 116OKIn the StoreControllerTest, the regular expression to test for price will validate incorrect price values.
assert_select ‘.price’,/\\$[,\\d]+\\.\\d\\d/
This expression will match the invalid price string
“$,.00”
Here’s the description of how << affects foreign keys that I was confused about earlier in the book when this was done. Maybe this description should be moved up to the first time << is used to append to a collection of children.
2010-11-20I removed the need for describing this earlier (I changed the code to call .build), and left this description here. 188SUGGESTYou forgot to menthion other changed parts of depot_r/app/mailers/notifier.rb from depot_p/app/mailers/notifier.rb.
I had to download, look at the source code, and apply changes. Otherwise, the test in P. 191 will give you errors.
default :from => “from@example.com”
to
default :from => ‘Sam Ruby <depot@example.com>’
and
def order_shipped
@greeting = “Hi”
mail :to => “to@example.org”
end
to
def order_shipped(order)
@order = order
mail :to => order.email, :subject => ‘Pragmatic Store Order Shipped’
end
How about a quick (one or two sentence) description here of RSS and feeds and Atom, rather than assuming the reading knows what Atom feeds are?
2010-11-20 178OKWhen I follow the steps to this point and try to view the Atom feed, I get a 406 Not Acceptable in my logs and nothing returned to the browser.
2010-11-20Can't reproduce 180SUGGESTYou should mention that “bundle install” needs to be run as root.
2010-11-21 189OK“<%= render @order.line_items %>” is indented wrong
2010-11-20 191SUGGESTSome things required to make these tests pass were not mentioned earlier: updating the order_shipped method, changing the default from address, etc.
2010-11-19 193SUGGESTThe book doesn’t mention what method in the new integration test file these lines should go in.
2010-11-20 194SUGGESTThe email set up earlier was simply “<depot@example.com>”, not “Sam Ruby <depot@example.com>”, which makes this integration test fail.
2010-11-19 171TYPOThe orders_controller_test.rb listing has a minor typo, as the end of file does not follow the “should create order” test, as suggested by the listing:
assert_redirected_to store_path
end
end
Perhaps replace the last ‘end’ with a #.. construct as used to show the missing code at the top, e.g.
assert_redirected_to store_path
end
# …
Second sentence under VIEW reads “By default, Rails scaffolding provides edit, index, new, and show, as well as a
partial named form that is shared between edit and show.” Shouldn’t the last word of this sentence be “new”?
First sentence under CONTROLLER reads “…one each for the five models, and the three additional ones FOR TO support the views…” which makes little grammatical sense.
2010-11-21 91OKIn the seeds.rb file, image_url is in the format of ‘/images/image.jpg’. in the index, you show the images with image_tag(product.image_url).
The image_tag helper prepends ‘image/’ so the image urls were appearing as ‘images/images/ruby.jpg’ resulting in broken image links.
removing ‘images/’ from the image_url in the seeds.rb file.
2010-11-21The image_tag helper will only prepend 'image/' if the argument does not start with a slash 198TYPOYou describe the encrypt_password method as “We’ll write this as a private class method.”, but this fails with a call to private method error, and besides, the full listing of user.rb on the following page shows it to be included as a public method.
2010-11-23 198OKDue to an error on my behalf, I forgot to add the “require ‘digest/sha2’” line to the model user.rb, yet the code still works.
Further testing shows the Digest::SHA2.hexdigest call to work within rails without the require statement.
So, if you forgive the pun, is the ‘require’ required at all?
2010-11-23If it turns out to be the case that some place in either Rails or something Rails depends on already includes that require statement, and has done so before this point, then this require is redundant. But depending on that is unwise, so it is best to include the require. 200ERRORThe password= writer method described fails as written, as no encrypt_password method is defined for the class, but for the object.
In other words, the line:
self.hashed_password = self.class.encrypt_password( password, salt)
… fails, but works when rewritten as:
self.hashed_password = self.encrypt_password( password, salt)
Note also the full code listing for user.rb a couple of pages later, which has the same error.
2010-11-22 198TYPOYou describe the encrypt_password method as “We’ll write this as a private class method.”, but this fails with a ‘call to private method’ error, and besides, the full listing of user.rb on the following page shows it to be included as a public method. So, suggest change to “We’ll write this as a public class method” instead.
2010-11-23 221SUGGESTThere appears to be an extra unneeded blank line at the end of the set_i18n_locale_from_params method.
2010-11-23 190OKFYI, #45642 here is probably a duplicate of #45156, the one I ran across (406 Not Acceptable with nothing displayed in the browser). I tried debugging for a bit but couldn’t figure out how that HTTP code was returned instead of the expected feed.
2011-01-26Marked as dupe, still investigating #45885 81SUGGESTI had a hiccup interpreting the rails generate command on p81 and believe it may be helpful to change the structure of that command so its obvious that there is no space between ‘\\’ and ‘title:string.’ A space results in compilation errors and db migration attempts.
As a newbie to RoR this feels better:
rails generate scaffold Product
\\title:string description:text image_url:string price:decimal
add in the Spanish translation needs to be named add_html because it contains an escaped ntilde character.
2010-11-22 229TYPO“<%= render ‘form’ %>” is indented wrong
2010-11-22 231TYPO“<raw msg>” should be “<%= raw msg %>”
2010-11-23 246SUGGESTI assume you’ll fix this, but “set password for ’some_user’@’some_host’ =OLD_PASSWORD(’newpwd’);.” runs into the margin.
2011-02-26 250SUGGEST“# optional task to reconfigure databases” This comment doesn’t make sense. The task below is doing a bundle install, but it’s described as reconfiguring databases?
2010-12-20 70OKCan the classes Employee and Person used in the example please be changed to something else?. Having Employee inheriting from Person looks like the old classic issue of modeling roles using inheritance instead of composition.
2010-11-28 253SUGGEST“Note that in this case an explicit require of active_support is that active support has not been configured yet, and that one of the configuration options that rails provides is to not include Active Support libraries at all”. Maybe it’s just the grammar that’s throwing me off (already mentioned), but I don’t even understand the point that’s being made about Active Support libraries being provided or not.
2010-12-20 269SUGGEST“The rails script is what is run when you run the rails command while inside the application directory.” This is redundant. On the previous page, you already said: “This directory also holds the rails script, itself. This is the script that is run when you run the rails command from the command line.”
2010-12-20 196SUGGESTorders = Order.find(:all) should be changed to
orders = Order.all as find(:all) has been deprecated and will be removed in version 3.2 of Rails.
“The next line verifies that there is a h3 element with the title of the Rails book that we had entered previously.” should read “The next line verifies that there is a h3 element with the title of the Ruby book that we had entered previously.”
2010-12-18 125TYPOLast paragraph on the page: in the sentence “…and rails uses these conventions”, “rails” should be capitalized.
2010-12-18 127TYPOIn the paragraph starting “While we haven’t talked about the assign method to date…”, “assign” should read “assigns”.
2010-12-18 223TYPOA form_tag block has been added under the banner div in application.html.erb, but is not marked as a change (little triangles needed).
2010-12-18 225ERRORAfter making the changes to the YAML files, it may be worth repeating that a server restart is required for the translation to work.
2010-12-20 225OKThe drop-down appears bang in the middle of the banner, as coded in the preceding application.html.erb, and looks horrid to my eyes. Plus, it is not displayed at all in Figure 15.3. I would suggest moving it to the bottom of the side div to maintain some visual sanity.
2010-11-28What drop-down? 236OKThe contents of the form_tag addition on this page (236) already figure in the preceding code listing on PDF page 223-224. This corresponds with my previous errata submissions (#45753, #45757). Best to remove the code from the first page, as the explanation that follows in pp 236-237 introduces the change and fixes the layout.
2010-12-21You must be reading beta 10 at this point... this was fixed in beta 11. 39OKIn 2 places you list how to start the rails server. You say “rails server”. That will just create a new rails application. To start the server you enter “ruby script/server”.
2010-11-27That's how it was done in Rails 2.x. This changed with Rails 3. 29TYPOIn part of the installation instructions you mention “sudo port install rb-rubygem”. It should be “sudo port install rb-rubygems”. NOTE the added “s” on the rubygem.
2010-12-17 391ERRORThe sql server date and time related mappings does not match for sql server 2008.
Sql Server 2008 supports addtional column types like date and time, and they are used by the sql server active record adapter(latest version 3.0.6) to map the rails time and date types.
rails type | sql server 2008 | sql server 2005 or 2000 |
:date | date | datetime |
:time | time | datetime |
I haven’t tested that for sql server 2005 and 2000 but I assume that it should be this way as it is in the book or in the table above. Sql server 2005 and 2000 doesn’t support the date and time type.
2011-01-26 189TYPO“Feel free to tailer this to your needs.” should be “Feel free to tailor this to your needs.”
2010-12-18 35OKIn the line: “NetBeans IDE 6.5 (some url here) sup-ports Windows”, the word “sup-ports” needs to be “supports” without a dash in the middle of it.
2010-11-27Duplicate of #45306 97TYPOFigure 7.1 should come after the closing “}”.
2010-11-28Duplicate of #44992 101OK“We can use the model’s valid? and invalid? methods to see whether it validates, and we can use the any? method of the error list to see whether or not there is an error associated with a particular attribute.”
These don’t appear to be methods of the model but of product_test.rb. Perhaps you mean the “validates” methods of the model.
2010-12-18In the example below this we see: \n \nproduct = Product.new; \n \nassert product.invalid?; \n \nassert product.errors[:title].any 102OK“…and we verify the error message associated with the price attribute is what we expect.”
It is not clear how one knows the error message one should expect here. It is not explicitly coded for the validation in product.rb (using “:message …”). Is it derived in some standard way from the statement:
“validates :price, :numericality => {:greater_than_or_equal_to => 0.01}” ?
“We’ll cover functional tests in more detail in Section 8.4, Iteration C4: Functional Testing of Controllers, on page 116. As for now, it is time for us to write some unit tests.”
It would be helpful somewhere in the previous section to include a brief description/differentiation of functional vs. unit testing.
2010-12-18Covered in section 8.4. 137OKThere is a ) near the end of this line with no matching (
format.html { redirect_to(store_url,
:notice => ‘Your cart is currently empty’) }
After adding precision and scale to the price decimal, I tried adding a decimal like 45.2341 and it stayed the same (it didn’t cut the last two decimals to 45.23). I still haven’t figured it out, but I found someone else following the book having the same problem. If this is normal, I’d suggest you put in a side note explaining why it doesn’t work. If not, please fix it!
2010-12-18Very observant! \n \nThe problem is that sqlite doesn't have proper support for decimals, it is only when you upgrade to a "real" database that you get the full benefit of decimal support. I do want to encourage best practice, but I don't want to get distracted at this early by covering this issue. 239ERROR“Add the locale to the products column” should be something like
“Add a locale column to the products table.”
Might be too detailed to get into here, but I’m curious what the difference is between inflect.singular/plural and inflect.irregular (when do you need to do the case-insensitive regex and when can you just do inflect.irregular, like you did in your example?).
2010-12-20 290OKI still haven’t seen an explanation at this point of how exactly things like “cart.items << new_item” work. Does it update foreign keys? Or just append to an in-memory list?
2010-12-20Just updates an in-memory list. Further explained on page 173. 118ERROR“The next three lines verify that all of our products are displayed. The first verifies that there are three elements with a class name of entry inside the main portion of the page. The next line verifies that there is a h3 element with the title of the Rails book that we had entered previously. These assertions are based on the test data that we had put inside our fixtures:”
And the third line…?
2010-12-18 292TYPO“:limit methodname”… “methodname” should have a space, but even with a space it doesn’t make the most sense.
2010-12-20 293OKThe “order(:id)” is confusing to me here. Why isn’t it “Order.find(id)”? What does lowercase “order” do?
2010-12-20the order method was described on the previous page 294TYPO“The :lock method” should say “The lock method”, following the convention that is used for all the other methods here.
2010-12-20 122TYPO121 has no erratum link so I’ll place it here…
“Rails makes the current session look like a hash to the controller, so we’ll store the cart in the session by indexing it with the symbol :cart_id.”
The first suggestion is that you place a brief description of what you mean by “store the cart in the session” here. By looking ahead to the sessions sections referenced on p.122 I was able to discover that you mean the actual contents of the cart are stored in the session info that is (presumably) shipped back and forth between client and server on every request (!).
The second suggestion is the explain the relationship/significance of the fact that a hash is used.
The third suggestion is that you explain why code is placed in application_controller.rb and not somewhere else. Although I have read ahead in the “Rails in Depth” section attempting to find out when this controller is used I was unsuccessful in finding an answer. I remain hopeful, however, that an answer will become readily apparent as I read on :).
2010-12-20Clarified that we are only storing the id of the cart (not the cart itself) into the session. 305OK“# Before saving or updating, encrypt the fields using the NSA and DHS approved Shift Cipher” That actually made me laugh out loud, but I’d hate to see someone take it seriously.
2010-12-20 305OKI just read “This example uses trivial encryption—you might want to beef it up before using this class for real.” You can ignore #45817 and keep the humor in :)
2010-12-20 125OK“#store .entry form, #store .entry form div {
display: inline;
}”
Does not seem to produce the desired formatting (on either Chrome or Firefox)
2010-12-18 127TYPO“As the build method is called on the @cart that will be used as one end of the relationship.” is a fragment…
2010-12-18 127TYPOCorrection on previous comment. I think you want a comma after @cart in the following.
“As the build method is called on the @cart that will be used as one end of the relationship.”
2010-12-18 128OKwe’ll tart it up in a minute
2010-12-18 65OKFrom the code listed on this page and judging by the code from a previous sample, this example seems to be wrong:
animals = %w( ant bee cat dog elk )
It should be:
animals = %w{ ant bee cat dog elk }
2010-12-18 118TYPObottom of page
“affect any data that already exists” should be “affect any data that already exist”
(data is plural)
2010-12-18 114TYPOIn the margin, yield -> page 64. This should be corrected to page 65 where yield is discussed.
2010-12-18 118TYPOThe next line verifies that there is a h3 element with
the title of the Rails book that we had entered previously.
The book is a Ruby book, not a Rails book.
2010-12-18 125OK#store .entry form, #store .entry form div {
display: inline;
}
Ignore previous comment. I found my error :)
2010-12-18 312OKHow about including details on model validation in the ActiveRecord section (in particular, how they’re stored and used by ActiveRecord)?
2010-12-21Validations aren't stored. The sequence of operations involved in validation is described in section 19.4. 322OKI’m curious at this point why id is referred to in the controller as “params[:id]” but format is simply “format”, even though they’re defined the same way in the route.
2010-12-20 138OKcleanup" should be "clean up
2010-12-18http://www.merriam-webster.com/dictionary/cleanup 84OKIteration A1 - start a local server.
You may want to point out that you must start WEBrick in the depot directory. If you have previously run the demo in a separate console it’s really easy to restart WEBrick in the demo directory and get a - No route matches “/products” - error.
2010-12-18The prompt and the paragraph afterwards seem sufficient. 224TYPO“15.2
Iteration J2: Translating the Store Front
Now it it time …”
I think that is “Now it is time”.
Ok?
Regards,
Paulo
HTTP menthod => HTTP method
2010-12-20 325SUGGESTFor consistency with similar explanations, explain in the “port_string” section what its value is if the port is the default port?
2010-12-20 326OKWould it be worthwhile to mention remote_addr in addition to remote_ip?
2010-12-20 327SUGGESTWhy mention erase_render_results here? If it’s undocumented, unrecommended, and should be used at your own risk, should you mention it at all? Or at least explain why someone would ever want to render twice per request.
2010-12-20 342SUGGESTSyntax for flash.now and flash.keep?
2010-12-21 343SUGGESTAn example or two with real code here might be useful. The constant stream of text is a little heavy, and seems inconsistent with other sections where theory is interspersed with snippets of code for those of us who learn better by example.
2010-12-21Added a link back to section 15.1 344OKIt seems like there is minimal information on testing in this third section of the book. Maybe everything needed is sprinkled throughout, but it might be nice to see a little section on testing at the end of talking about Active Record, Action Controller, and Action View.
2010-12-20 347OKIn this section (21.1), something I was expecting to see but didn’t was an explanation of <% , <= %> and <% -%>. In other words, a little blurb that says the template is interpreted and certain strings (explain which) that are found are interpreted and replaced like so…
2010-12-21Covered in section 25.2 350SUGGESTIs “scalar” the right word to use here? I looked it up in the index of the pickaxe book and it’s not there.
2010-12-21 351TYPOSomething weird going on with point #1 in the graphic. It looks like it says “to edit a userl.t reads the…”, but the rl.t are all smashed together.
2010-12-21 351SUGGESTSorry for the multiple comments, but I realized there are lots of weirdly-displayed things in this graphic. It says “users controller .rb” instead of “user_controller.rb”, in #3, “HTML” and “to” are smashed together, in step #4 on the right the image looks distorted, the arrow pointing from #4 to #5 is distorted, etc. I tried with Adobe Reader on Linux and Windows.
2010-12-21 351SUGGESTDon’t know how nitpicky you want to be, but the example on page 347 says “form_for :model”, but the image on this page says “form_for(:user)” (different parentheses styles).
2010-12-21 360SUGGESTThis is the only place in the book I’ve noticed <% -%> used instead of <% %>.
2010-12-21 367SUGGESTI thought the “h” method was not used in Rails 3.
2010-12-21 372OK“it’s invoked before filters are run”. The presence of absence of the apostrophe in that phrase completely changes the meaning… maybe reword it to be more clear?
2010-12-21 385OKIt would be nice in this chapter to see an explanation of best practices for approaching implementation of caching in an application. For example, how should a small application start, what elements should be added as the site grows, how should it be determined where the best gains will be made by improving caching, etc.
2011-08-25 383SUGGESTSame as a previous point. Should h() be used in Rails 3?
2010-12-21 110TYPOBottom of page, Note 1. Reads “…if you are managing your source code using git, you will want to use git rm index.html”
The command should be “… git rm store/index.html”
2010-12-18actually, git rm product/index.html 183OK“The default is to show 30 entries per page…”
It should be “10 entries per page”, not “30 entries per page”.
2010-12-18 177ERRORI get the same problem as #45642. When I run “curl”, I get the feed just fine. But when I go to “/products/3/who_bought” in the browser to subscribe to the feed, nothing happens and I get the following in the server console:
Started GET “/products/3/who_bought” for 127.0.0.1 at Fri Dec 03 19:11:53 –0500 2010
Processing by ProductsController#who_bought as HTML
Parameters: {“id”=>“3”}
Product Load (0.2ms) SELECT `products`.* FROM `products` WHERE (`products`.`id` = 3) ORDER BY title LIMIT 1
Completed 406 Not Acceptable in 20ms
Sorry, #45884 is not a typo, the default is indeed 30.
2010-12-18 43TYPOFigure 2.3 filename displays as “say_controllerb”. Copy and pasted it it appears as “say_controlle.rb”. Should be “say_controller.rb” I think.
2010-12-17 155ERRORThe link for download that code snippet is missing.
Also, the code doesn’t run. Rails gives an error. I believe it is where this call takes place:
<%= render(:partial => “cart_item”, :collection => cart.line_items) %>
Replacing this code with this:
<%= render(:partial => cart, :collection => cart.line_items) %>
Runs properly.
2010-12-18This is not meant to be downloaded, but there was an error on the render call. What was intended was: \n \nrender(:partial => "line_item", :collection => cart.line_items) 285OKShow migration for HABTM?
Maybe it is somewhere in the book, but as newbie when you get to the section on HABTM, it mentions the join table, but doesn’t really describe the migration. I think it might be nice to show it.. esp since you need the :id => false. Pardon if it’s mentioned somewhere that I missed.
2010-12-20 330TYPOrender(:json => stuff, [callback => hash] ) must be render(:json => stuff, [:callback => hash] )
see colon at :callback
2010-12-20 29TYPOMissing ‘s’ in sudo port install rb-rubygem
must be sudo port install rb-rubygems
The given code
resources :products, :shallow => true do resources :review
end
does not enable the recognition of the following routes:
/products/1/reviews => product_reviews_path(1) /reviews/2\t=> review_path(2)
Rails Version is 3.0.3
2010-12-20 184OKWhile following along with the Pagination section and carefully writing the code as instructed by the book, I found that it did not work. I would get an error while loading the index page for orders which complained that the paginate method was not found. After some time, I figured out that I needed to kill and restart the server.
2010-12-18There are instructions to restart the server -- to pages back. 359SUGGEST“This third parameter also supports two additional options that modify the behavior of the link.” The only option I can see mentioned is :confirm. Was this paragraph meant to be above the previous one, where the :method option is described? Otherwise, what is this second additional option?
2010-12-21 227TYPO“Both can be found in the product index template:”
should be “Both can be found in the STORE index template:”
2010-12-18 232TYPOThe code listing for views/orders/_form.html.erb does not internationalize name, email, and pay_type labels, so they end up being not translated, even though the screenshot on the next page does show translated.
2010-12-22Calling i18n functions explicitly is generally not required for labels. I clarified this in the text. 212SUGGESTFigure 14.3 should not show the enhancements to the sidebar (adding orders, products, users, logout) because those enhancements are not made until the next iteration.
2010-12-22 233SUGGESTThis paragraph:
“Since we once again made use of HTML entities, we will want these error messages to be displayed as is (or in Rails parlance, raw):”
and the corresponding single line of sample code appears to be accidentally placed too high in the document. It seems like it was meant to come somewhere after the next paragraph, which introduces the discussion of error messages. It is confusing where it is placed now.
2010-12-20 236TYPOThe image for Figure 15.8 is exactly the same as the image for figure 15.7. Figure 15.8 should show the words “name”, “address”, etc. all in spanish.
2010-12-22 58OKHighlighting “key words” or “Important words of the phrase” makes it more readable & easy to grasp.thanks Rajnish
Ruby Names
Local variables, method parameters, and method names should all start with a lowercase letter or with an underscore: order, line_item, and xr2000 are all valid. Instance variables (which we talk about on page 65) begin with an “at” sign (), such as
quantity and @product_id. The Ruby convention is to use underscores to separate words in a multiword method or variable name (so line_item is preferable to lineItem).
Class names, module names, and constants must start with an uppercase letter. By convention they use capitalization, rather than underscores, to distinguish the start of words within the name. Class names look like Object, PurchaseOrder, and LineItem.
Rails uses symbols to identify things. In particular, it uses them as keys when naming method parameters and looking things up in hashes.
For example:
redirect_to :action => “edit” , :id => params[:id]
As you can see, a symbol looks like a variable name, but it’s prefixed with a colon. Examples of symbols include :action, :line_items, and :id. You can think of symbols as string literals that are magically made into constants. Alternatively,you can consider the colon to mean “thing named” so :id is “the thing named id.”.
2010-12-18Not clear to me what is being requested here. 64TYPOAlmost halfway down the page, the book reads:
“Ruby statement modifiers are a useful shortcut if the body of an if, untilwhile or until statement is just a single expression.”
I think “untilwhile” should just be “while”
2010-12-18 53TYPOIn the second sentence of the last paragraph, the second parenthetical statement contains two full sentences separated by a comma. A semicolon would be better:
“…and a method (this button does a POST operation; other common methods are GET, PUT, and DELETE).”
2010-12-18 43TYPOIn the Figure 2.3 controller file name view as “say_controllerb” instead of “say_controller.rb”, but when this string is copy and paste the value is correct. This issue was mention when viewing pdf by Chrome 8.0.552.215 and Foxit READER 3.1.2.
2010-12-17 57OKI’m not sure PHP is best described as a web framework (“in other web frameworks, such as PHP or JSP”).
2010-12-18 157OKa minor but illustrative improvement on hidden_div_if():
def hidden_div_if(condition, attributes={}, &block)
if condition
attributes[‘style’] ||= ’’
attributes[‘style’] += ‘display: none;’
end
content_tag :div, attributes, &block
end
1) you introduce the idiom in the beginning of the book; here it is in action.
2) by applying “display:” additively, it covers more cases
3) leave it as an exercise to the reader to make it more robust (i.e. solve when the “display” attribute is already specified in the style).
The download link for show.html.erb comes back as html, not as text.
2010-12-18From the bottom of page 23 (in the section on Live Code): \n \nSome browsers (such as Safari) will mistakenly try to interpret \n some of the templates as HTML. If this happens, view the source of the \n page to see the real source code 93SUGGEST“The only tasks that remain are to initialize a database..”: Maybe substitute repository for database so as not to confuse the reader with the database created earlier in chapter.
2010-12-18 104SUGGEST“Note that you do not have to include the id column in test fixtures.” This is the first time the id column is mentioned; it was never explained.
2010-12-20 119TYPOAfter the “products attribute must not be empty” test:
you state that ‘two tests executed’ when your rake test:units output clearly shows one test executed.
These observations relate to server configuration, not Ruby on Rails and come from the perspective of a Linux newbie.
I have setup an Ubuntu 10.10 server and installed Ruby 1.9.2 and Rails 3.0.3.
1. Public key generation description implies that key generation is done on the server whereas it should be done on the client and copied to the server.
2. No description for installing Apache2, rake or rack.
3. Apache 2 config should not contain the directive NameVitualHost. This is already in ports.conf and the reference should be deleted or made clear its in ports.conf
4. The httpd.conf file should be edited to include “ServerName localhost” and the DocumentRoot.
5. Apache2.conf should not contain the virtualhost block as best poractice would be to create a file for each domain such as mydomain.com and www.mydomain.com in sites-available. Then issue the command sudo a2ensite mydomain.com to enable the site.
6. The rails application should ideally be placed in a common directory such as /var/www/myapp rather than a home directory and then issue sudo chown myapp user to give write permissions to udate the code.
7. sshd_conf does not need to be edited. Any editing is outside the scope of this book as it will work without editing.
8. On my machine, at least the capistrano script hung on bundle install as bundle asked for a password but the script did not ask for input. I had to comment out the bundle part of the script and load the gems manually.
8. I suggest that postgres install should be mentioned in addition to mysql and that the need to install libpq-dev before gem install pg be included.
Seasoned linux users may gloss over some of these details but they are a minefield for newbie users such as myself. Thanks for a wonderful book!
2010-12-20(mostly) beyond the scope of this book 146TYPO…and one set of for when…
2010-12-18 146TYPO…with code to which causes…
2010-12-18 152TYPO“…in the rails server window…”: Rails is not capitalized.
2010-12-18 133OKi’m using the iPad version: pg 133
near the top is: ..“similar layout-the designer”..
I believe this to be a typographic error as the “-” between ‘layout’ and ‘the’ is unnecessary
There are references to single table inheritance on this page and also in the index but it looks like STI has not been covered yet. Is this an over sight?
2010-12-20 171TYPOIn the paragraph introducing the code to add to order.rb, “line item” should be plural. That is, change “…indicating that the line item that belong to an order…” to “…indicating that the line items that belong to an order…”
2010-12-18 114OKinsert a link to download the logo image (logo.png)
line 12 - image_tag
untilwhile" in the middle part should be "while
2010-12-21 78OKOn the the graph, the relationship between Order and Line Item is confusing. 1..n should be from Order to Line Item not the reverse.
2010-12-21 226TYPOIn the code example that begins on p.225 and extends onto p.226, there is block of 13 lines that are marked with triangles indicating that those lines have changed. I can see how the first 4 lines have changed, but the remaining lines in the block appear not to have changed from what was there before.
2010-12-22 96OKin paragraph “Why test against 1 cent, rather than zero? Well, it’s possible to enter a number such as 0.001 into this field”
The number should be 0.01 rather than 0.001
2010-12-22The problem that needs to be caught is entering numbers that would round to zero. 215TYPO“logoff” should be “logout”.
2011-01-25 131OKConcern of @line_item.save
Maybe I am a little bit picky, but there is a rare case that if the same use logs in to the website in 2 different sessions, it may cause dirty read problem.
It is necessary to do dirty read check so that the value must not be changed since it was retrieved.
2011-08-25 131OKConcern of @line_item.save
Maybe I am a little bit picky, but there is a rare case that if the same use logs in to the website in 2 different sessions, it may cause dirty read problem.
It is necessary to do dirty read check so that the value must not be changed since it was retrieved.
2011-01-25Dupe of #46081 145OKDuplicated [Empty cart] button. The button should be removed from depot_j/app/views/carts/show.html.erb
2011-01-25where's the other [Empty cart] button? 148OKIt is obvious that the Total is wrong in the image.
It should be 184.9*2 = 369.80
As written:
scope :last_n_days, lambda do |days|
where(‘updated < ?’, days)
end
gives a runtime error “in `lambda’: tried to create Proc object without a block (ArgumentError)”
Correct form is
scope :last_n_days, lambda { |days| where(‘updated < ?’, days) }
once we have passing tests.
(consider) once we have passed the tests. (or something so verb is correctly used)
2011-01-24 122OKBit new to the subject (hence the book) but shouldn’t line_items be using :through to establish it’s has_many relationships. It seems this would lead to cleaner code in several cases.
2011-08-25 167TYPOFigure 12.1 has an arrow indicating @order.name maps to the :name attribute on the label and this is why the text box contains Dave. I believe the mapping should be to the :name attribute on the text_field instead.
2011-01-26 92OK<%= stylesheet_link_tag :all %> in application.html.erb
doesn’t add depot.css to the css’s resulting in no alternating background colors.
here is a snippet of the html code generated:
.
.
.
depost.css lives in the depot.db folder presently, if I copy it to the depot.stylesheets folder no change occurs to the generated html code (only scaffold.css is contained within :all).
2011-01-24 92OKPlease withdraw my previous submittal re: depot.css. Evidently I didn’t have depot.css in the correct folder. Now rails generates the following HTML as it should:
and the alternating colors work fine now.
Hope I found this before I wasted your time.
Respectfully,
Capitalize “rails”.
2011-01-25 21SUGGESTDevelopers are worried about deployment, too.
remove the comma. it is not needed.
=> Developers are worried about deployment too.
2011-01-24 19OKLine 1. “Ruby on Rails is a framework that makes it easier to develop, deploy, and maintain web applications.”
I suggest you remove the comma after deploy.
=> Ruby on Rails is a framework that makes it easier to develop, deploy and maintain web applications.
2011-01-24 105OKIn reading (and re-reading) about adding the fixtures directive in test/unit/product_test.rb it is not clear to someone new to Rails why. I see a lot of “Rails is already doing this” and if “The name of the fixture file determines the table that is loaded, so using :products will cause the products.yml fixture file to be used.” seems like the fixture file will already be loaded based on it’s name. MY SUGGESTION: Explicitly tell/show what will happen with & without this directive being in place. (or is this directive redundant to what will be automatically done by Rails. BTW great book!!!!
2011-01-25There already is a paragraph which says that it is not needed. 105SUGGEST‘The products method indexes into “that” table. We need to change the index used to match the name we gave in the fixture.’ By the time we get to this paragraph it is not a clear tie to which “that” table refers.
2011-01-25 186TYPOCapitalize rails in “sending e-mail in rails”.
2011-01-25 191TYPOCapitalize html in “create html formatted e-mails”.
2011-01-25 23OKUnder “Live Code”, you mention that links can be clicked to display code. This worked great in Safari, for Ruby files, until recently - now it will download the file instead of displaying it. Anyone know a way to change this? If there’s a solution, maybe it could go in the book - the feature is so convenient I feel lost without it :)
2011-01-24 119OKPlaytime #2 suggests playing with the various options of the number_to_currency method, but the first one I tried (:locale => :fr - taken from the API documentation) doesn’t change anything for me - the currency amounts are still shown in dollars (my locale is US). I’m using Rails 3.0.1 and Ruby 1.9.2. [The other options shown in the API docs DO work, BTW.]
2011-01-25Locale is covered in chapter 15 242OKThe host machine and development machine might have different versions of ruby.
Address the problem of getting these synchronized. I think there’s nothing for it but to do a ruby
install on the host. Then there’s the problem of ensuring that the passenger apache plugin picks-up the
right ruby version. How does that work?
If the ruby versions are different, then bundler and gems will not create an image that is portable from
the development machine to the host machine.
Even if the ruby versions are the same, some gems install machine specific native extensions. One such gem is mysql2, I think. The
image created by the bundler on the development machine is incompatible with the host machine.
Bundler must run install on the host machine to make that installation whole. Capistrano can help
execute that task.
Gemfile.lock seems helpful for locking versions. The vendor/bundle, vendor/cache breaks because even
the same version of a gem can install differently on different machines in different environments. Am I
wrong about that?
How do you ensure that the cgi program or passenger module run rails with RAILS_ENV set to “production”?
I don’t think it is sufficient to add that setting to .bashrc or .bash_profile.
How does ‘bundle install’ interpret the development, test, and production environments of Gemfile? Does
it install everything? How about ‘bundle pack’? (But the lock file production of ‘bundle pack’
is likely the only useful effect.)
My attempt at following along with the Task K deployment chapter has resulted in the output from ‘cap
deploy:migrate’ reproduced below. After over a day of poking-about for the solution,
the above observations aren’t helping me. Perhaps they are getting in the way?
I do know that developing a small sample application on the host machine according to the host
provider’s instructions did work. Now I’m working to discover the differences.
* executing “cd /home/user/domain/releases/20101228015253; rake RAILS_ENV=production
db:migrate”
servers: [“domain”]
[domain] executing command
* [err :: domain] Could not find sqlite3-ruby-1.3.2 in any of the sources
* [err :: domain] Try running `bundle install`.
command finished
My host provider wanted:
gem ‘mysql2’
and
adapter: mysql2
There were some differences in the other database.yml settings as well, such as reconnect:true
So as you say, “something like”
2011-01-26 140SUGGESTIn the switch from views/carts/show.html.erb showing an unordered list to a table, the loop changes from
“cart.line_items.each do |item|" (crf. p128 & p131) to
"for item in
cart.line_items” (also on p144). Both technically work, but the more Ruby-ish “.each do |item|” should probably be used throughout (until OBE by the creation of the partial).
“We use the current_cart method we implemented on PAGE 121 to find (or cre- ate) a cart in the session.”
referenced code is now on pg 122.
2011-03-02 444TYPOFirst full paragraph, second sentence reads “We recommend that you start by vising the rubyonrails…” - missing a “t” in “vising”.
2011-01-26 124TYPOapp/controller/line_items_controller.rb should be app/controllers/line_items_controller.rb
2011-01-25 146OKwhen moving on to partials the @ is missing from the cart object on
td class=“total_cell”><%= number_to_currency(cart.total_price) %>
making the application throw a siyntax error on the code highlighted fro _cart.html.erb
right line should read
td class=“total_cell”><%= number_to_currency(@cart.total_price) %>
great book otherwise. I find a few errors that take me a while to get throught -like why is the @cart variable being destroyed when I got to te application view? anwyay thx, m
2011-01-25The @ is *supposed* to be missing (this is even explicitly stated in the paragraph above this code). Omitting the @ would not have been a syntax error but rather a runtime error, so I suspect that another syntax error may have been involved? 155TYPOThere is already an error submitted for this piece of code, however it misses the point. The version of the cart partial, ie _cart.html.erb on page 155 is plain wrong. if you follow the book all along, the last version of _cart was created on page 146 and it does not contain “:partial =>”line_item" ….." the line is instead “<%= render(@cart.line_items) %>”.
I ask, is this some kind of error from the last version of Rails?
Manuel
2011-01-25 29ERRORsudo port install rb-rubygems (instead of rb-rubygem, missing an s)
2011-01-24 398OKIn the following paragraph you are referring to the “line item migration in the preceding section” but the preceding section does not actually have a line item migration.
“Extending Migrations
If you look at the line item migration in the preceding section, you might wonder
about the duplication between the two option parameters.”
In the code in section 10.1, some of the key/value hashes lack spaces….like these:
LineItem.create :cart_id=>lineitem.cart_id,
:product_id=>lineitem.product_id, :quantity=>1
As a newbie, it starts an internal conversation: "Are these a different kind of hash? Do these non-spcaed hashes mean something else…something that hasn’t been explained.
So, you might want to examine and/or reconsider. Thx!
2011-01-25The key values match attribute names in the LineItem ActiveRecord object. 201SUGGESTThe tutorial begins to get a bit fuzzy in this section regarding what is a public method and what is a private method. Only way to determine proper placement is to look at the downloaded code.
2011-01-25 101ERRORText describes that the reader will see two tests executed after running rake test:units, however, the sample output shows 1 test executed (as if we removed the original “the truth” unit test).
2011-01-25 19OKMalachy O’Connell’s suggestion to remove the , after the word deploy on p19 line 1, is not an optional comma. Don’t remove it.
2011-01-24 44OKIn version 3 of the book, there was a great part under dynamic content that is quiet important, I do not know if it was moved to another part of the book I haven’t yet gotten to, but it should be a must have. It’s the section that discusses the use of when to use/not to use = sign after the <% and why to use the - sign before %>.
2011-01-24Now section 25.2. The description about why to use the - sign before %> is gone because it no longer applies. 127TYPONear the top of the page: “We then pass that product we found in to @cart.line_items.build” should have “into” instead of “in to”
2011-01-25 158OKWhy would you hide the cart on all pages and do the silly cart = current_cart statement in all of your controllers if you could just add a before_filter to set
cart in the application_controller?
before_filter :current_cart
private
def current_cart
cart ||= Cart.find(session[:cart_id])
rescue ActiveRecord::RecordNotFound
cart = Cart.create
session[:cart_id] = cart.id
@cart
end
Sam’s response to #45881 is incorrect. It should be ‘git rm public/index.html’.
2011-01-25 97TYPOIn the end of page 96 begins validation, and after image on page 97 is “}”, would be nicer if its together
2011-02-26 121SUGGEST9.1 modifies the ApplicationController for the first time. It would help us nubs to have a sentence or two of introduction as to the effect of adding code here.
Also, the protect_from_forgery could use a brief mention.
(PS - Great book so far — thanks!)
I don’t see anything on rvm management of ruby,rails,.. environments. This is useful stuff.
2011-08-07 28OKDo you really mean ‘sudo gem uninstall rubygems-update’ in paragraph 1.2?
2011-01-24yes. It was installed, and run, and can now be safely uninstalled. 255TYPOBroken link near “Find more options at …”
The topic DeploymentTips does not exist on wiki.rubyonrails.com.
Under Instantiating Observers, it says “you need to list them in your application’s environment.rb file (in the config directory)” when it should say “you need to list them in your application’s APPLICATION.RB file (in the config directory)”
2011-01-26 171SUGGESTI found the modification of the line items test fixture to be confusing. Before modification the fixture records have the keys ‘product_id’ and ‘cart_id’. The book modifies the fixture records keys to ‘product’ and ‘cart’. I find this change in keys without explanation to be a source of confusion.
2011-01-25 188TYPOMiddle of page… app/mailer should be app/mailers.
2011-01-25 248TYPOOn the first paragraph of section 16.2 Iteration K2, the first line reads:
“If you have are a large shop …”
but should read:
“If you are a large shop …”
2011-01-25 208TYPOTowards the middle of the page, ‘session#create’ should be ‘sessions#create’ as the controller class name is sessions.
2011-01-25 296TYPOI stumbled over the use of “relations” in the line “Relations are equivalent to an anonymous scope:”. Perhaps my issue is due to not reading enough of the preceding text, but it seems like you are using the word “relations” where you mean to use the word “scope”.
2011-01-26 181ERRORGemfile contains:
gem ‘rails’, ‘3.0.4’
what may result in following Error:
Could not find gem ‘rails (= 3.0.4, runtime)’ in any of the gem sources listed in your Gemfile.
Solution: Either change the Gemfile version to 3.0.3 Or upgrade your System to RoR 3.0.4 (apparently a repeated application of instructions from the beginning of the book does not leverage Mac Users version from 3.0.3 to 3.0.4 yet …)
2011-01-26 249SUGGEST$ cat /.ssh/id_dsa.pub >>/.ssh/authorized_keys2
Suggest adding some way to update known_hosts so cap doesn’t get hung up on the authentication prompt.
2011-01-25 75TYPOIn section 5.2, subsection “Use Cases”, right in the first sentence:
A use caseis simply…..
Should be a space after “case” and before “is”.
2011-01-24 133SUGGESTMinor niggle - “LineItem”.underscore => “line_item”
This line of code:
LineItem.where(“quantity>1”).each do |lineitem|
should probably be:
LineItem.where(“quantity>1”).each do |line_item|
2011-01-25 61TYPOThere is a missing space.
First sentence, second paragraph. After “interpolation”
“Second, Ruby performs expression interpolationin double-quoted strings”.
2011-01-24 96TYPORight at the beginning of paragraph 4, :presence => truetells…
Should be a space between the word “true” and “tells”.
2011-01-24 96TYPOIn paragraph 5, second sentence:
We’ll use the delightfully named numericalityoption to verify…..
Should be a space between the words “numericality” and “option”.
2011-01-24 96TYPOParagraph 5, sentence 3:
… verbosely named :greater_than_or_equal_tooption a value….
Should be a space between “:greater_than_or_equal_to” and “option”.
2011-01-24 28SUGGESTIt is not clear what to install from the SQLite download page.
“Next, install SQLite3.2 Download and unzip two precompiled binaries for Windows:” could be rephased to “Next, install SQLite3.2 Scroll down to ‘Precompiled Binaries For Windows’ Download and unzip two precompiled binaries for Windows:”
2011-01-24 136OKWhen I entered the code “redirect_to store_url” I was prompted with a message saying that there was no store_url or neither store_url attribute. I changed to this :
flash[:notice] = “invalid cart”
redirect_to :controller => ‘store’, :action => ‘index’
and it worked fine.
I’m new to Rails and I might have made some mistake. Since I’m learning Rails with this book.
2011-01-25On page 110, you should have added: \n \nroot :to => 'store#index', :as => 'store' 116SUGGESTIn section 8.3, it describes a change to the “index template”, but doesn’t specify a filename like the other sections do, when discussing changes to files (the file is in app/views/store/index.html.erb)
It’s also not formatted like those other sections with a filename, code listing, and an arrow identifying the changed line.
2011-01-25 102OKproduct_test.rb
trying to enter a negative price returns a different error message
product.price = –1
assert_equal “must be greater than or equal to 0.01” … fails
error message generated is: “is not a number”
ruby1.9.2-p136
2011-01-25This test consistently passes for me. 64TYPO‘ifexcept’ and ‘untilis’ should each be made into two separate words.
2011-01-24 149OKstore_url for the redirection didn’t work for me. I’ve used “redirect_to :controller=> :store, :action => :index” instead.
2011-01-25On page 110, you should have added: root :to => 'store#index', :as => 'store' 151TYPOShouldn’t it be “A .js.rjs template” ?
2011-01-25 165OKredirect_to store_url, :notice => “Your cart is empty”
return didn’t work for me. I’ve used redirect :controller => :index instead.
In part II, you iteratively “build” an application
looks like this should this read as …
In part II, you iteratively “built” an application
There’s a great deal of web information about CMS’s to manage ‘static’ content i.e. a non technical client wanting to occasionally change a few web site details, as opposed to adding a new book (application data) to the worked example provided. Some recommendation on how to allow users to change content would be useful as a CMS like Radient or Refinery seems to be against the grain with the RoR framework.
2011-01-26 99OKNeed a “changed” triangle at the line near the end of the page beginning “assert_redirected_to product_path(…”
35c35
< assert_redirected_to product_path(assigns(:product))
—-
> assert_response :success
The book is pretty clear, but I can’t make heads or tails out of the “Playtime” section of the website for ch10. This also happened in Ch9.
Could there be some kind of visual indicator of which submitted solutions are better and why? Because I’m learning, having a badge by the names, to identify a moderator, or the best solution, would help me understand better, and notice the differences.
Think Yahoo answers, where at least there’s an indicator to let you know which answer won.
Otherwise, seeing all the opinions from different students just confuses me.
2011-06-17 295TYPOOn the side note it reads ‘lamdba -> page 71’ where it should read ‘lambda’
2011-01-25 61OKLast Paragraph re. phrase “nil is an object, just like any other, that happens to represent nothing.” This phrase is useless and explains nothing. Objects do not “represent” anything. nil is an object with a specialized behavior which can be described.
2011-01-24 112TYPOThe right parenthesis to the “Note: …” is missing.
2011-01-25 367TYPOMissing space between second and third word of paragraph which begins with: “The :partialparameter”
2011-01-25 152OKIncluded with Rails is a number of JavaScript libraries.
should read
Included with Rails are a number of JavaScript libraries.
In the line “The rails generate command logs…” the word “nothing” lacks an h.
2011-01-25The word is http://www.thefreedictionary.com/noting. 244OKIf you are using RVM for managing your Ruby version(s), I recommend reading the “Configure the Web Server” section of the RVM website (integration/passenger page).
This should avoid any “no such file to load — bundler” error messages from Passenger.
The other [Empty cart] button is in depot_j/app/views/carts/_cart.html.erb, which duplicates that in depot_j/app/views/carts/show.html.erb
2011-03-02It is not just the button that is duplicated between those two files: both show the entire cart including the button. The intent of iteration F1 is to get to the point where app/views/carts/show.html.erb is no longer being used. 295OKSome of the code extracts in Rails in depth section look like they should be runnable in the example cart system built earlier, but can’t, eg:
PAGE 295:
result = Order.group(:state). order(“max(amount) desc”).limit(3)
It looks like the state column was in an older version of the system, can be confusing when trying things out
2011-03-04 75TYPOUse Cases
A use caseis
Should be
A use case is
MySQL is not included on all versions of OS X. (At least not on my late-2010 MacBook Air.)
2011-08-25 2830SUGGESTsqlite3-ruby gem is now sqlite3, so I think better if we address this
gem install sqlite3
2011-03-02 194ERROROn page 194, the integration test file
user_stories_test.rb
generated by
rails generate integration_test user_stories
reads:
require ‘test_helper’
class UserStoriesTest < ActionController::IntegrationTest
…
But when I look at the file generated by the command in textmate it reads:
require ‘test_helper’
class UserStoriesTest < ActionDispatch::IntegrationTest
…
< ActionController::IntegrationTest
vs.
< ActionDispatch::IntegrationTest
Do you guys get the same result?
Best,
F
2011-03-03 205OKThere are missing yellow > characters for the lines that are changed in the file depot_r/app/views/users/index.html.erb. Only arrows are shows for lines that have been added near the top of the file.
2011-03-03Sadly, it is not possible to put arrows next to deleted lines. 217OKIn the rails console example command, the following section is rendered in the incorrect color (should be maroon indicating command input, not blue for command output):
:password_confirmation => ‘secret’)
In the second paragraph, first sentence, there should be a space between the words “default_url_options” and “also”
2011-03-03 99OKI have been following along in the book, and most things are explained really well. I usually feel comfortable and understand what is happening as we do it. In this part, I realize that rake test threw a few errors, but what do they mean? Why are they happening? How does this piece of code that we added make a difference. I just have no idea what just happened. When I am coding in the real world, I won’t be able to just download a piece of code and throw it in. We need to know why things are happening and how we fix it.
2011-08-28 71TYPOMissing whitespace in Block lambda and require betweet methodname and description
2011-03-02 281ERRORRegarding booleans in databases this page reads:
“In the case of Boolean, it turns out that not all databases have a native boolean type. In the case of MySQL, a value of 0 is used for false, and a value of 1 is used for true. Unfortunately, Ruby treats everything that is not false or nil as true, so direct usage of these values is problematic.”
In the old days the raw attribute reader returned an integer, but nowadays the value is converted to a boolean (by default, there’s a configuration flag that may disable the conversion). So the user has no access to the integers in practice, and thus direct usage is no longer problematic (although it is not idiomatic).
May I suggest to weaken or obviate that part?
The rest of the explanation introduces predicates (appending a question mark to the attribute name), and it is fine.
2011-08-25 151OKTo make the ajax call work I had to change the line from:
format.js
to:
format.js { render :layout => false }
or else the javascript code would have been returned to the browser incapsulated into the #main div of the layout (not valid javascript code). I don’t know if it’s a typo in the book or a bug in rails3.
“MIME type you’d like returned”.
Shouldn’t it be “MIME type you’d like to be returned ?”
At the top of the page the following code sample seems wrong:
verbose_greet(“Dave”, “loyal customer”) { puts “Hi” }
Instead of listing variable names for the accepted parameters it has actual strings as if this was a method call, not a method definition.
2011-03-02 270TYPO“In here you place static (in other words, unchanging) web pages, such as stylesheets, JavaScript, and perhaps even some web pages.”
Repetition of web pages.
Shouldn’t link_to for the :delete be button_to since it is a destructive action? In IE the confirmation would come up, but was ignored (cancel ->deleted). Changing to button_to resolved.
2011-03-04link_to is what the scaffolding generates; and it should work, even on IE 96SUGGESTFor the coded example at the bottom of the page the ending “}” is not showed until after Figure 1.7. I would make sure that is stays with the code example to stop any confusion.
2011-02-26 171TYPOPar. 1, sen. 1 reads:
“Note that when we removed the _id suffix from the attribute name.”
Need to strike the word ‘when’.
“Note that we removed the _id suffix from the attribute name.”
I think the source code of the demo application should build up sequentially. But here the functional test is taken from depot_g, while the examples before and after are taken from depot_f. The functional test should move to depot_f to be in line.
2011-03-02 292OKIn the discussion of sorting (aka order) this is done on the Order table so I initially thought the Order.where(…).order(“”) was doing something on an order object as opposed to a sort. May be better to use a different table such as Product.where(…).order("title, DESC) to not overload the meaning of order in the example.
2011-08-25 293OKThe brief sections on joins and groups are useless as they stand unless you know SQL. Maybe I am expecting too much but being able to find related records from other tables to the entries you have found in the main table seems fairly fundamental - I suspect this is what join is trying to do but this one paragraph fails to give me any idea how to do this.
2011-08-25 252DEFERThis code from the deploy.rb file I believe is outdated:
after “deploy:update_code”, :bundle_install
desc “install the necessary prerequisites”
task :bundle_install, :roles => :app do
run “cd #{release_path} && bundle install”
end
In any case, it does not seem to work. The forums suggest that removing this and inserting:
require “bundler/capistrano”
is the correct statement.
I should note that this is not working for me. I continue to get an error preventing bundle install from working.
Thanks.
2011-03-10 112OKproducts should be
product in views/store/index.html.erb (line 7)
The line “@product = products(:one)” I believe requires that the file text/fixtures/products.yml be filled with data though that isn’t described and done until pg 103-104. products(:one) is a call to “row” :one in that fixture file. I’m converting all of the testing to rspec but that line confused me until I got to the bottom of page 103.
2011-03-02That line is not modified here; it is generated by the scaffolding as is the corresponding test data. You are correct that the explanation comes in 4 pages. 411TYPOThe example shows an initial price of 49.5 Then $5 is taken off. The image shows a price of $24.95 and the wrong book title. ??
2011-03-04 410OKThe magic shown in the bottom half of the page needs some tweeking of the Gemfile - if the database in Depot is not the default (sqlite3)
2011-03-03 293ERRORThe path to the hosts file in windows is wrong. It should be c:/windows/system32/… and not c:/system32/…
Very good book. Kind regards
“We can see the mapping between SQL types and their Ruby representation in Figure 19.1, on the following page.” Figure 19.1 is on the same page, not the following page.
2011-03-03 281SUGGEST“everything that is not false or nil as true”. Wrong font used for “true” (the code font should be used, but the normal italic font is used instead)
2011-03-03 282TYPO“In the Depot application. LineItems have direct relationships […]” There should be a comma after the word “application”, not a period.
2011-03-03 132OKIn db/migrations/xxxxcombine_items_in_cart.rb on pages 132/133 of pdf.
Spaces need to be added around “=>” in lines like:
. . .
sums.each do |product_id, quantity|
if quantity > 1
# remove individual items
cart.line_items.where(:product_id=>product_id).delete_all
# replace with a single item
cart.line_items.create(:product_id=>product_id, :quantity=>quantity)
end
. . .
lineitem.quantity.times do
LineItem.create :cart_id=>lineitem.cart_id,
:product_id=>lineitem.product_id, :quantity=>1
end
. . .
As written w/o spaces, they didn’t work for me.
2011-03-03spaces are not significant in this context in Ruby; adding them causes the line to spill over 301OKYou cover destroy methods on this page but there are no examples of how to destroy related records.
It would be really usefull to show for example how to delete all orders related to a product that have been cancelled to show how active record relationships can be destroyed with conditions
I’m on Snow Leopard and I got sqlite3 stuff going but I ended up messing around with this until I got it. Don’t remember specifics but of everything so far (on page 100) 1.2 was the biggest ‘hiccup’. You might have someone do a sanity check that a simpleton like me will blow through this with Snow Leopard. I can’t remember my issues but this was my only wtf page so far.
2011-03-04Unfortunately, that's not enough to go on for me to figure out the problem. 315TYPO“/users, /user/1” should read “/users, /users/1”
2011-03-03 322TYPO“Some controllers can be resourced based” should read “Some controllers can be resource based”.
2011-03-03 324SUGGEST“If it doesn’t find one and the controller implements the method_missing, that method is called […]”, suggest replacing with “”If it doesn’t find one and the controller implements method_missing, that method is called […]" or “If it doesn’t find one and the controller implements the method_missing method, that method is called […]”
2011-03-03 328SUGGEST“So will the following (as the default action of a controller is to call render if the action doesn’t)” is a little confusing… maybe replace with something like “So will the following (as the default behavior of a controller is to call render if the action doesn’t)”
2011-03-03 329SUGGEST“If the template needs instance variables, these must be set up by the method that calls the render.” should probably end in either “[…] calls render” or “[…] calls the render method”
2011-03-03 356SUGGEST<%= @page_title || “Pragmatic Store” %>
appears without any introduction.
2011-03-03 356SUGGEST“Because we’re in the store controller, we edit the file store_helper.rb in app/helpers (as shown on the next page)”. This is not shown on the next page, but rather immediately after that paragraph, on the same page.
2011-03-03 30SUGGESTinstead of the for loop
for cmd in ; do which $cmd; done
a simple
which ruby irb gem rake
shows the same info and is easier to understand to non shell users
Section 26.4, start of second paragraph:
“Let’s look at at the RJS” => “Let’s look at the RJS”
2011-03-03 101OKSection entitled: “A Real Unit Test”, about halfway down:
“Replace the the truth test with” => “Replace the truth test with”
2011-03-02The name of the test is "the truth" 157ERRORPage 157 says “We’ll write our helper so that it is local to the store controller by adding it to application_helper.rb in the app/helpers directory:”
Shouldn’t it say “We’ll write our helper so that it is local to the store controller by adding it to store_helper.rb in the app/helpers directory:”?
2011-03-03 160TYPOPage 160 says “We used :remote => true to invoke the LineItem.new action using Ajax.”
Shouldn’t it say “We used :remote => true to invoke the LineItem.create action using Ajax.”?
2011-03-03 31ERRORtyping sudo gem install sqlite3-ruby, gives the following messgae::
Hello! The sqlite3-ruby gem has changed it’s name to just sqlite3. Rather than
installing `sqlite3-ruby`, you should install `sqlite3`. Please update your
dependencies accordingly.
Thanks from the Ruby sqlite3 team!
2011-03-02 81TYPOwork> rails new depot
has to spaces to the left of “rails”.
2011-03-02 89TYPOdepot> rake db:seed
has two spaces to the left of “rake”.
2011-03-02 100TYPOIn the last but one paragraph: “but here ActiveSupport is combining a class method”.
“ActiveSupport” would be “Active Support”.
2011-03-02 112TYPOAs per the general style in ERb templates used in the book, “<sanitize product.description>” lacks a space to the right of the equal sign.
2011-03-02 116SUGGESTThe rationale given for using a helper instead of “sprintf(”$%0.02f“, product.price)” is potential i18n.
This is a very distant risk. May I suggest saying instead that it is likely that depot will need to display the price of a product in several places, and wouldn’t be a good practice to repeat the format of a price all over the views. That is: introduce a helper because it gives you encapsulation/code reuse, which is a much more common need than i18n, and one that fits well depot at this stage of its development.
2011-08-28 118TYPOThis page starts with an orphan “end”. Guess the book still needs to pass through a final revision of these details, but just in case :).
2011-03-02 30SUGGESTWhen following the following provided directions on my Snow Leopard iMac, my path is different than the typical value provided:
“All you need to do here is verify that each command is found in the same path, typically /opt/local/bin.”
On my system, the “for cmd in ruby irb gem rake; do which $cmd; done” command displays the following:
iMac:~ Matt$ for cmd in ruby irb gem rake; do which $cmd; done
/usr/bin/ruby
/usr/bin/irb
/usr/bin/gem
/usr/bin/rake
If my result is typical, maybe change the /opt/local/bin to the /usr/bin path.
2011-03-04You are good to go! 124SUGGESTThe ERb snippet at the top of the page checks whether the cart is empty using line_items.count.zero?
Association collections provide line_items.empty? as a more specific way to check precisely that.
2011-03-09 130SUGGESTThe migration name patterns “add_XXX_to_TABLE” and “remove_XXX_from_TABLE” do not match the example “rails generate migration add_quantity_to_line_item quantity:integer” because “line_item” is not a table name.
The example works because the migration generator pluralizes whatever it captures as TABLE, but anyway the patterns and the example differ in that detail.
May I suggest renaming the migration to “add_quantity_to_line_items”?
2011-03-09 75TYPO(page number is from iPad version)
first link_to example…
Time to say
<%= link_to “Goodbye!”, say_goodbye_path %>
should have ! outside of ERb to be consistent with prior example, as in
Time to say
<%= link_to “Goodbye”, say_goodbye_path %>!
(Totally minor! :-)
2011-03-09 174OKThe URL at the top of the page that points to the documentation of fixtures in the Active Record API has an ar subdomain (I do not reproduce it here to avoid the spam filter).
Rails components had individual APIs in the past, but a few months ago we decided with David that they weren’t worth the trouble. The corresponding rake tasks have been removed, and the procedures that generate the Rails docs only generate API and guides nowadays. (Note the 2008 in the that page.)
May I suggested to point to the same file but in the Rails API?
2011-03-09This needs to be fixed in Rails itself: \n \nhttps://github.com/rails/rails/blob/master/railties/lib/rails/generators/test_unit/model/templates/fixtures.yml#L1 183TYPONear the top of the page: “we will modify our controller to call paginate”. Since “paginate” is a method name guess you’d use fixed-width font there.
2011-03-09 187DEFERThe :test delivery method for development is handy, but still pushes mails into AM::Base.deliveries, an array we normally do not care about in development mode. I normally set config.action_mailer.delivery_method to false, which does not even do that.
I think it is worth mentioning that in any case you can see the email in the log, should you check it is working fine, copy an activation URL, etc.
2011-03-09 196TYPOThe arrow of “:name\t=> ”Dave Thomas“” both in 196, and 197 is not aligned with the rest of the arrows of the hash.
2011-03-09 196TYPOThe second argument in the calls to assert_equal in the snippet in the middle of the page are aligned except one (order.email). Same on page 197.
2011-03-09 233TYPOActiveRecord -> Active Record.
2011-03-09 255DEFERThis page explains config.active_support.bare and says “In fact, one of the configuration options that Rails provides is to not include Active Support libraries at all”.
That’s not exactly that way, you get some AS included in your application.
The applications has whatever AS extensions are needed for the framework itself. Rails has been refactored to cherry-pick from AS strictly what’s needed (in theory, of course), but still that’s quite a lot.
Suggestion here would be to explain this, or to add perhaps a footnote about it.
2011-03-09 naERRORThe only reference to _add_price_to_line_item.rb is in eBook version B.12 at Page 387?
So up to this point a migration has not taken place which includes any ‘price’ or ‘total orders’ being displayed in the Admin area. If anyone knows how to fix this, I’d appreciate it! Thx
2011-03-09 157OKunder the application_helper.rb code,
attributes[“style”] = “display: none”
shouldn’t that be
attributes[“style”] = “display: none;”
CSS needs a semicolon
2011-03-09In CSS, semicolon is a statement separator, not a statement terminator: \n \nhttp://www.w3.org/TR/2002/WD-CSS21-20020802/syndata.html#q8 127OKI believe the code segment on this page has a technical error/typo. Shouldn’t “assert_redirected_to cart_path(assigns(:line_item).cart)” be “assert_redirected_to cart_path(assigns(:line_items).cart)?”
With :line_items being plural?
Hi, I have the second, the third, and the beta of the fourth edition. But I am somewhat disappointed about the latter one. As someone familiar with older versions of rails, I would have expected a chapter about what’s new and different in rails 3 from older rails versions (or older editions of the book). A need to read the whole book in order to - maybe - find the differences is too much of an overhead.
2011-06-17Not in scope for this book. The information you seek can be found at: \n \nhttp://edgeguides.rubyonrails.org/3_0_release_notes.html 452SUGGESTThe index reference to Git for development leads to a page that has nothing to do with Git (107). The page after has some information. But the best info can be found on page 93. (A2 Playtime)
2011-09-05 268TYPOThe sentence “In previous versions of Rails, the files in the lib directory were automatically included in the search.” seems to be incomplete. There’s no “search” going on in the context of that paragraph.
2011-06-18 272ERRORThe application’s load path does not contain subdirectories of app/models. Also, the config directory is not included in $:.
2011-06-18 278OK“These objects” near the bottom, has too much whitespace in between. I’ve observed this in other places, particularly after the first word starting a section. Check for example “So far” in “Grouping Controllers into Modules”. “Newcomers to” in “Naming Conventions”, etc. there a quite a few of them.
It is my understanding that you have a document generation pipeline that outputs LaTeX. In my experience it is very strange that LaTeX produces such whitespace. First, if you manually type a series of spaces LaTeX collapses them. Second, the algorithms to layout paragraph rarely leave holes like that, you know they are really good at this.
So this ticket just raises a flag, in case there’s something in the LaTeX generator or somewhere else that introduces these spaces somehow.
If the LaTeX source looks fine, please disregard this ticket.
2011-06-18I don't see this in the original source, the PDF (when viewed from a desktop machine), or in the printed book. Perhaps it is a problem with generating one of the other eBook formats? 280OKThe first paragraph in this page says “Rails obtained this information by asking the underlying database the first time we tried to use the Order class.”
Just a comment here. AR lazy loads the metadata from the database, you could use a model class without triggering that.
It is a nuance, perhaps deserves a footnote, or perhaps it was decided not to mention it for the sake of simplicity, which would be fine.
2011-06-18 286TYPOActiveRecord -> Active Record, in the second paragraph.
2011-06-18 288SUGGESTFully-qualified constant name for RecordNotFound?
2011-06-18 291SUGGEST“Order.where(”name = :name and pay_type = :pay_type“, {:pay_type => pay_type, :name => name})” has explicit curlies.
You know that’s not very idiomatic, and “Order.where(:name => params[:name], :pay_type => params[:pay_type])” in the same page has none.
There are more curlies like that in the book. If they are deliberate that’s fine, opening a ticket just in case.
2011-06-18 296OKThere’s a find_by_sql call that concatenates three strings. That’s not very common in Ruby, you know, we normally use a multiline %{} or a heredoc.
Also seen on page 297.
2011-06-18 313TYPOActionPack -> Action Pack in “Each of these activities was orchestrated by modules in the ActionPack component.”
2011-06-18 324SUGGESTIn “If none of these things happens, an Unknown Action error is generated.” the words “Unknown Action” are in fixed width font.
I think that needs either lowercase and regular font, or else “AbstractController::ActionNotFound” in fixed-width font.
If you are quoting the error message in the rendered page, that’d be “Unknown action” with lowercase “a” and regular font.
2011-06-18 326ERRORThe accepts request attribute is an array with Mime::Type objects that represent the MIME types in the Accept header.
The format attribute is unrelated to the Content-Type header. It may be defined by a virtual extension, eg /posts.xml, or by the Accept header (tricky, see implementation), with Mime::HTML as fallback.
The request object does not respond to the following methods: mime_type, path_without_extension, path_without_extension, path_without_format, path_without_format_and_extension, relative_path.
2011-06-19 329ERRORrender :file no longer accepts a :use_full_path option.
2011-06-19 139TYPOminor typo…
“Now when we view our cart and click the Empty Cart button”
should be “Now when we view our cart and click the Empty cart button”
In the last paragraph of the page: “You know you how to add that field to the view.”
2011-06-19 349ERROR“You use the text and text_area helpers (on lines 4 and 9, respectively) to gather single-line and multiline input fields.”
Should be “text_field and text_area helpers”
2011-06-19 29SUGGESTThe last command on page 29 is “sudo gem install sqlite3-ruby”; this command notifies the user that the gem has been renamed to just “sqlite3”. You might want to update the doc to reflect this. The full message given by the gem install command is:
Hello! The sqlite3-ruby gem has changed it’s name to just sqlite3. Rather than
installing `sqlite3-ruby`, you should install `sqlite3`. Please update your
dependencies accordingly.
There several things to revise regarding session stores:
- Classes implementing session stores do not belong to CGI::Session. All belong to ActionDispatch::Session except ActiveRecord::SessionStore. The configuration code knows where to look for depending on the symbol.
- The values :p_store, :drb_store, :memory_store, and :file_store are no longer valid.
This option also accepts a custom session store (don’t know whether that’s in the scope of the book though).
2011-08-25Resynchronized with http://guides.rubyonrails.org/caching_with_rails.html 346TYPOThere’s a list item that reads: “The current controller object is accessible using the attribute named controller. This allows the template to call any public method in the controller (including the methods in ActionController).”
At the end it should say “ActionController::Base”.
2011-06-19 350SUGGESTFootnote 3 links to the edge guides. Those document the master branch, if possible it would be better to link to the stable guides.
2011-06-19 351ERRORThe flow in Figure 21.2 starts with the “edit” action. Steps 2, 4, and 5 are consistent with it (except for a missing “_method” parameter in 4), but step 3 shows a form for creation.
2011-06-19 362ERRORThe first complete paragraph says: “If the path given to an asset tag method includes a forward slash, then the path is assumed to be absolute, and no prefix is applied.”
In order to consider the path to be absolute, it has to start with a forward slash. Mere inclusion is not enough.
2011-06-19 369OKThe first ERb snippet has this render call:
render(“shared/header”, :title => @article.title)
I think this idiom has not been introduced. That is, the idiom that does not use an explicit :partial option and passes locals in an ordinary hash.
2011-08-07This is where the idiom is introduced. :-) 375SUGGESTThis line of code
“expire_page\t:action => ”public_content“”
has a lot of whitespace between the macro and the symbol for no apparent reason.
2011-06-19 380TYPOThe second paragraph has “ActiveRecord” in fixed-width font. Should be “Active Record” with a space and regular font.
2011-06-18 380SUGGESTIsn’t it a bit strange that created_at is used for :last_modified?
It is rare that an application does not allow the author to edit an article after publication. Guess updated_at would be a more realistic timestamp to base expiration on.
2011-06-19 401OKFootnote 1 links to the Rails wiki, but the wiki went down a while back and there’s no plan to resurrect it. Nobody noticed, it was not maintained and completely out of the radar of core. We decided with David that its time had arrived :).
2011-06-19Wiki appears to be back up 438TYPOjQuery has a lowercase “j”, but there are several occurrences of “JQuery”. A global search and replace here.
2011-06-17 439TYPOIn “and to remove the now unnecessary prototype libraries”, capital “P” for Prototype.
2011-06-19 441TYPO“devise” should be in fixed-width font to be consistent with other plugin names.
2011-06-19 441TYPO“ActiveRecord” -> “Active Record” in “For example, datamapper replaces ActiveRecord”.
2011-06-18 444TYPO“We recommend you start by visiting the rubyonrails site” -> “We recommend you start by visiting the Ruby on Rails site”.
2011-06-19 444TYPOThe “and”s in this enumeration are fine?
“There also are plenty of related categories that go beyond Ruby and Rails, such as Agile Practices, Testing, Design, and Cloud Computing, and Tools, Frameworks, Languages.”
2011-06-19 160TYPOShould be a comma after the second occurrence of “test” in the third paragraph. ie. “This test differs in the name of the test, in the …”
2011-06-17 90TYPOIn the paragraph:
Now that we have the stylesheet all in place,
stylesheet should be stylesheets
2011-06-17 123OKI was confused with the relationship between belongs_to, and product_id / cart_id, as well as the use of .build on p126, so it may be worth explaining this more. Is it a rails naming convention that foreign_key fields end in _id ? Must they be defined in the table by the user, and as integers, rather than just by using belongs_to ? Does .build also assume the _id naming convention ? Also, to access e.g. the product_id, do I use e.g. line_item.product.id or line_item.product_id ?
2011-06-17How it works is described later... in section 19.2. For now, it is sufficient that the build method understands how has_many and belongs_to work. 262TYPO“and not with all that much code” should probably read “and with not ….”
2011-06-18 131OKHere we change from using cart.line_items.build to cart.add_product to make use of new line_item quantity field. Could use of cart.line_items.build be disabled ? Or could it be overridden with a modified method, rather then using cart.add_product ?
2011-06-17 127TYPOWith respect to the explanation of the “assigns” method:
“This method gives us access to the variables that have been (or can be) assigned by views.”
Perhaps I’m being overly pedantic, but the following wording seems clearer to me:
“This method gives us access to the instance variables that have been (or can be) assigned by controller actions for use in views.”
This is similar to how “assigns” is described at guides.rubyonrails.org/testing.html
2011-06-17 171TYPOFourth line from top:
“instead, the id attributed should match…”
should probably be:
“instead, the id attribute should match…”
2011-06-17 179TYPO(Roughly the middle of the page)
“Products have many line_items and line_items belong to a order.”
should be:
“Products have many line_items and line_items belong to an order.”
2011-06-17 187ERRORIn the last line test file name is given as notifier.rb it should have been notifier_test.rb
2011-06-17 111OKin css, for #main you show padding-top: 4ex;, I believe you mean 4em;
2011-06-17 78TYPO“In Rails, a model is automatically mapped to a database tablewhose name is the plural form of the model’s class.”
A space is missing between ‘table’ and ‘whose’
2011-06-17 152OK<%= hidden_div_if(…) do %>
should be:
<% hidden_div_if(…) do %> [at least for Rails 3.0.5]
Adding the ‘=’ generates syntax error as the ‘do’ is enclosed in a .to_s call
2011-06-17Tested and works for me 192ERRORFor installing will_paginate, i’ve run “bundle install”. Then go to browser and reflash page of localhost:3000/orders ,nothing but an error shows that Order.paginate can not be invoked.
so i restart rails server,and it comes ok now.
do you think it’s better to remind readers for this ?
2011-06-17 231TYPOFigure 15.8 should show translated attributes according to the text (Page 230, last paragraph: “We are pleased to see the model and attribute names translated in Figure 15.8,
on the following page”). They don’t.
What about creating user unit tests too.
2011-06-17 132TYPOIn the sentence:
“Armed with all this background about flash data, we can now change our show method to intercept
bad product ids and report on the problem:”
‘product ids’ should be ‘cart ids’
2011-06-17 211SUGGESTSome pages still work when no user is logged in - this is no longer tested as for all tests, a user is pre-logged in. Might be better to add “login_as :one” in specific tests.
Also, tests missing for redirection back to login when no-one is logged in.
… mapped to a database tablewhose name is the …
should have a space between table and whose
… mapped to a database table whose name is the …
Problem with store_controller_test.rb, the test fails if you use the code as outline in the book however if you change the following line:
assert_select ‘#main .entry’, 3
to
assert_select ‘#main > .entry’, 3
then it works as expected and the test passes.
2011-06-17 24TYPOThis suggests that this is not the final version:
“This beta book was written using Rails version 3 (specifi- cally Rails 3.0.5 at the current time).”
Running the load_orders.rb script with rails runner does not seem to populate the Orders table. What would be really useful in the book is to actually mention how to debug each step in case something goes wrong. The command simply executes with no indication of what happened. At this stage, no logging or printing to the console is discussed.
2011-08-28Logging is mentioned previously (see, for example, section 10.2), and syntax errors show to the screen. Without knowing more specifics as to what problem you are seeing, I don't know what to recommend. 20ERRORKindle location 411 (don’t know if that’s searchable)
on creating a local version of rails docs, the book missed the step “bundle install”
rails_apps> cd dummy_app
dummy_app> bundle install
dummy_app> rake doc:rails
Under Generating the Scaffold, second paragraph: the word “tablewhose” is one word.
2011-06-17 100OKOn page 100 there is a page break which seem out of place. The phrase looks like this :
“Instead, as we’ll
see shortly, the name gives us a convenient way to reference test data inside our test code.”
This leaves half of page 100 empty for no apparent reason.
2011-06-17Unfortunately, that's an unavoidable difference between the PDF version and the print version. 156156OKtask_f fails functional tests out of the box.
Downloaded code
rake db:migrate
rake test:functionals
(in /home/dnehme/sandbox/agilerailsbook/from_authors/code/depot_f)
Loaded suite /home/dnehme/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
…….E…………..
Finished in 0.503925 seconds.
1) Error:
test_should_create_line_item(LineItemsControllerTest):
ActiveRecord::RecordNotFound: Couldn’t find Product without an ID
CSS for id main has a bad unit type:
#main {
…
padding-top: 4ex;
…
}
since all the other unit type in that piece of css are em’s I believe it should be
#main {
…
padding-top: 4em;
…
}
hitting the “add to cart” causes an error “NoMethodError in LineItemsController#create” undefined method `save’
this is because the cart.add_product function is returning current_item.quantity not current_item
easy to fix by add a line after current_item.quantity += 1 :
current_item
Paragraph 6, beginning, “You can create and initialize…” the end of that line is “aset”, should be “a set”
2011-06-17 82SUGGESTYou could better explain the reason your assert_equal uses the statement “product.errors[:price].join(‘; ’)” The text says you “use the handy join method to concatenate each message” and “express the assertion based on the assumption there is only one such message.”
Then why not just use product.errors[:price][0]? It better illustrates what your text explains. The join seems somewhat convoluted.
2011-06-17 162TYPOIn the sentence “The combination of form_for and the various field-level helpers (such as text_field) give it this information.”, in my opinion, ‘give’ should be ‘gives’ as it is ‘the combination’ that gives the information, i.e. 3rd person singular.
2011-06-17 290ERRORActive Record Callbacks have been changed (figure 19.2 and page text is outdated). Instance method “overwrites” for callbacks are deprecated in favor of class method handlers. Both instance methods and class handlers for before_validation_on_create/_on_save and after_validation_on_create/_on_save have been removed in favor of new class handler before_validation(:on => :create) patterns. There also new callbacks for handling transaction commits and rollbacks.
2011-08-28 230ERRORFigure 15.7 should be switched with Figure 15.8 according to their legends.
2011-08-08 18OKThe location is listed as demo1, it should be demo — see following:
…the current file is shown as, at the bottom of page:
work/demo1/app/controllers/say_controller.rb
…it should be:
work/demo/app/controllers/say_controller.rb
I believe OrdersController::create() needs to set cart in the else (failure) case on the
order.save. If order.save fails due to validation errors, render :action => "new" is executed. But our application layout expects
cart to be set in the hidden_div_if() call.
I recommend the following addition in order_controller.rb, create() method:
if order.save
...
else
>
cart = current_cart
…
end
Alas, Deploying Rails Applications (ZT08) is out of print - see elsewhere on pragprog.com - and the version of chapter 6 available online seems to have no great relevance to deployment on Windows. (new edition on the way?)
2011-06-17 113OKre #46865 : Works for me per the text. Has Joel got a space between “#main” and “.entry”?
2011-06-17 112OKre #46977 : Works for me per the text. Has Ian omitted the “current_item” immediately before the function “end” ?
2011-06-17 209OKIsn’t it good idea to include discussions on ‘authenticity_token’ and ajax request, protect_from_forgery?
2011-08-25 255TYPOIn the first sentence in the “A Place for Supporting Libraries” section on page 255 there should be a space between “Thelib” that is it should be: “The lib”…
2011-08-07 257TYPOOn page 257, in the section entitled: “A Place for Static Web Pages”, there should be a space in “Thepublic”, that is, it should be “The public”…
2011-06-18 90SUGGESTThis might be a good place to explain why “Product” products, but "Store" store. And also: why your command “rails generate controller store index” has lowercase “store” but your previous command “rails generate scaffold Product…” has uppercase “Product”. (Or, whether it matters.) It’s confusing.
2011-06-17I fixed the case portion of this comment. As this hasn't fundamentally changed over the past several editions of the book, I would rather wait to hear if more people find this confusing before addressing the rest. 96SUGGESTThe inconsistent use of bold text in your HTML tags on this page (and elsewhere) is somewhat confusing. Is this the new text to be typed by the reader? No, it’s not (in this case). I suggest using consistent text formatting for HTML tags and wherever you indicate text changes need to be made.
2011-06-17 122OKAfter following the code on page 122, the CSS was not applying correctly to the main cart view. I changed the “#store” id to “#main” for the newly added CSS, and this applied the CSS.
2011-06-17 208TYPOIn the first paragraph of 15.2 there is a space between I18n.translate and the closing sentence period.
2011-06-17 33ERRORrails_apps> rails new dummy_app
rails_apps> cd dummy_app
dummy_app> rake doc:rails
This step fails for me on OS X 10.6 with built-in Ruby 1.8.7, RubyGems 1.8.4, rake 0.9.0, Rails 3.0.7.
Trace output below:
rake aborted!
undefined method `task’ for #
/Library/Ruby/Gems/1.8/gems/railties-3.0.7/lib/rails/application.rb:215:in `initialize_tasks’
/Library/Ruby/Gems/1.8/gems/railties-3.0.7/lib/rails/application.rb:139:in `load_tasks’
/Library/Ruby/Gems/1.8/gems/railties-3.0.7/lib/rails/application.rb:77:in `send’
/Library/Ruby/Gems/1.8/gems/railties-3.0.7/lib/rails/application.rb:77:in `method_missing’
/Users/justin/dummy_app/Rakefile:7
/Library/Ruby/Gems/1.8/gems/rake-0.9.0/lib/rake/rake_module.rb:25:in `load’
/Library/Ruby/Gems/1.8/gems/rake-0.9.0/lib/rake/rake_module.rb:25:in `load_rakefile’
/Library/Ruby/Gems/1.8/gems/rake-0.9.0/lib/rake/application.rb:495:in `raw_load_rakefile’
/Library/Ruby/Gems/1.8/gems/rake-0.9.0/lib/rake/application.rb:78:in `load_rakefile’
/Library/Ruby/Gems/1.8/gems/rake-0.9.0/lib/rake/application.rb:129:in `standard_exception_handling’
/Library/Ruby/Gems/1.8/gems/rake-0.9.0/lib/rake/application.rb:77:in `load_rakefile’
/Library/Ruby/Gems/1.8/gems/rake-0.9.0/lib/rake/application.rb:61:in `run’
/Library/Ruby/Gems/1.8/gems/rake-0.9.0/lib/rake/application.rb:129:in `standard_exception_handling’
/Library/Ruby/Gems/1.8/gems/rake-0.9.0/lib/rake/application.rb:59:in `run’
/Library/Ruby/Gems/1.8/gems/rake-0.9.0/bin/rake:31
/usr/bin/rake:19:in `load’
/usr/bin/rake:19
In the code continued from page 226 from file (depot_s/app/views/orders/_form.html.erb) t(‘.pay_type’) seems to be missing for the payment type label. This also seems to be missing from the downloadable example code.
For the es configuration file on page 227 (depot_s/config/locales/es.yml) for pay_type it says “Pagar con” while in the screenshot on page 228 it depicts Forma de page.
2011-08-07For the first point, the very next sentence says "Note that we do not normally have to explicitly call I18n functions on labels, \n unless we want to do something special like allowing HTML entities." \n \nNot marking this comment fixed until I resync the screen capture. 229TYPOAfter completing the code additions depicted on page 229 the error displayed do not match figure 15.7. Rails complains that “translation missing: es.activerecord.models.order” This error occurs even after using the downloadable code in depot_t.
2011-08-29 375SUGGESTWould it not be better to check for the fragment with fragment_exist?() instead of read_fragment() to determine if the database trip is necessary? The call to read_fragment() actually reads it in, while fragment_exist?() does not and accomplishes what is desired.
2011-06-19 402SUGGESTThe ActiveResource example does not work with the authentication added to the depot application developed in the book. I modified the authorize() method in the application controller to handle basic authentication as well by applying that when the Mime::XML type was requested. I don’t recall if this was something optionally added through the exercises (I went through this fairly quickly just to catch new Rails 3 stuff), but it was confusing at this point. I use the standard authentication otherwise for non-XML requests. I suggest adding something here to make basic authentication work because the ActiveResource section is very important IMO.
2011-08-28 143OK‘#cart, #cart table’ should be ‘#side, #cart table’ in depot.css
2011-06-17tested and works for me 258TYPO“Thevendor” -> “The vendor”, first paragraph of “A Place for Third-Party Code” section.
2011-06-18 259TYPO“Theconfig” -> “The config”, first paragraph of “A Place for Configuration” section.
2011-06-18 260TYPO“What you put into these configuration file” -> “files”, first paragraph.
2011-06-18 227TYPOI’m using Rails 3.0.7. It seems that the labels for :name, :email and :pay_type do not pick up their localized values automatically until the model itself is localized on page 230. The picture on page 228, therefore, doesn’t look like shown in (my?) reality.
2011-08-25 207ERROROn the bottom it says that “it sets the locale in the session from the params”, but actually there is no assignment to ‘session’ in the code.
Furthermore, the whole sentence is not really understandable - what does “it leaves the locale alone” mean?
The logging facility explanation introduce a security vulnerability:
it is suggested to log the cart name (#{params[:id]}) directly into the log file. This input (as every user input) need to be sanitized otherwise you end-up with a log injection attack.
Because this book is mainly for beginner, emphasizing that user input should not be trusted is very important so they get good habits.
The link to the download references depot_c instead of depot_b. The depot_b test file matches the changes shown in the book.
2011-08-07 85OKJust below the middle of the page the gray box for displaying the file name is missing for:
test/unit/product_test.rb
The gray box should be above the code snippet that adds
fixtures :products
Thanks…
2011-08-07 102SUGGESTThe shaded text boxes containing the file names are very helpful.
Would it be possible increase the font size of the file names in the next edition so that the file names are easier to read?
Thanks.
2011-08-30(Dave Thomas here—I'm afraid not—those names can get quite long, so the size we've chosen is a compromise between readability and practicality) 108OKThe last paragraph at the bottom of the page says to add a different product to the cart, but the illustration shows the cart with duplicate items:
- Programming Ruby 1.9
- Programming Ruby 1.9
Might be nice to mention in the last paragraph that in order for multiple items to be displayed in the cart the browser must be configured to accept cookies (at least from localhost for those who have their browsers set to not accept cookies by default).
Thanks.
2011-08-27 103TYPOAt the top of the page, the shaded box with the file name is missing for app/models/cart.rb
2011-08-07 108SUGGESTFor show.html.erb code, at first it wasn’t clear whether or not the code listing is replacing all of what was already in show.html.erb.
There are several other instances in the book where this isn’t clear (too vague, I know). I’ll try to note other instances when I see them.
In this case it might be nice to explicitly say something like:
To prevent the message box from displaying, delete
<%= notice %>
2011-08-07 105SUGGESTAt the end of the paragraph above the code listing for depot.css it would be nice to mention that this is a new code block to be added to the /* Global styles */ section.
(In other words, it doesn’t replace or modify any code that’s already there.)
Thanks.
2011-08-07 134TYPOThe first sentence of the first paragraph under section 11.3 Iteration F3: Highlighting Changes reads “Included with Rails is a number of Javascript libraries.” This should read “Included with Rails are a number of Javascript libraries.” Or, perhaps, “A number of Javascript libraries are included with Rails.”
2011-08-07 170ERRORWhen I try to save an order which is not filled, the “Pay type” appears twice instead of one.
one is text_field and another is select.
The current version of line_items create does not work.
2011-08-07Works for me: http://intertwingly.net/projects/AWDwR4/checkdepot-30/section-9.3.html 63ERRORThe total method needs to have a value returned from it. Something as simple as “sum” would do.
I am providing a sample below.
def total_wrong
sum = 0
line_items = [10,20,30,40]
line_items.each {|li| sum += li}
end
def total_correct
sum = 0
line_items = [10,20,30,40]
line_items.each {|li| sum += li}
sum
end
puts “Wrong: #{total_wrong}”
puts “Correct: #{total_correct}”
The rake test failures that updating products_controller_test.rb should fix don’t get fixed with the depot_c file that is provided.
2011-08-07Works for me: http://intertwingly.net/projects/AWDwR4/checkdepot-30/section-7.1.html 85SUGGESTTEXT FROM BOOK:
“(Note that this code uses %{…}. This is an alternative syntax for double-quoted string literals, convenient for use with long strings. Note also that because it uses Rails’ create method, it will fail silently if records cannot be inserted because of validation errors.)”
I have some seed data that used to work in an earlier version of rails, but not in rails 3.1.
turns out i needed to add the “magic comment”. This line at the top of my file was both necessary and sufficient for my seeds.rb to be processed correctly:
- coding: utf-8
to the very very top of the script.
this should be mentioned here so that you can accept special characters such as the registered trademark symbol, etc., in seed data while still being able to use the convenient %{…} syntax mentioned as advantageous for use with long strings.
it should probably just be with the default file anyway since rails3 supports utf-8 and may even assume it is there?
2011-08-07 147TYPOOn the first line the coma is misplaced (I guess).
“The return statement is important here; without, it you will…”
Should be:
“The return statement is important here; without it, you will…”
BTW: My book version isn’t listed. It reads:
P1.0 printing, March 2011
Version: 2011-3-11
After title “13.1 Iteration H1: Sending Confirmation Emails” on page 169 the first word is “Thereare”, but should be “There are”
2011-08-07 343TYPOShould the end of the second paragraph say “helpers that come with Rails”?
2011-08-07 414TYPO“…it therefore it is possible to avoid…” -> “…it therefore is possible to avoid…”
2011-08-07 120OKThe ‘private/end’ section in the code example (product.rb) does not appear in the downloadable code and causes an error.
2011-08-07 210OKskip_before_filter is deprecated in Rails 3 - this is a version 2.x function
2011-08-07not deprecated 217TYPOScreen-shot shows for pay_type: “Forma de pago” but on page 216 you wrote “Pagar con”. Furthermore the form field “name” and “pay_type” aren’t translated in this stage.
2011-08-25 127112OKKept receiving error “You have a nil object when you didn’t expect it!” from the line:
line_item =
cart.add_product(product.id)
Changed the line to
line_item =
cart.add_product(:product_id)
and everything works.
2011-08-07Works for me: http://intertwingly.net/projects/AWDwR4/checkdepot-30/section-10.1.html 424TYPONear bottom of page 424: “You know you how to add that field…”
2011-08-07 26SUGGESTSnow Leopard users wishing to install Ruby 1.9.2 instead of using the stock 1.8.7 version with Rails should do the following:
sudo port install ruby19 +nosuffix # Installs Ruby 1.9.2 without the “1.9” suffix into /opt/local/bin
(“sudo port install rb-rubygems” is now unnecessary, as gem is installed with Ruby 1.9.2 by default.)
The rest (from gem update —system onward) is still applicable. I did find that, even though “which ruby irb gem rake” showed them all in /opt/local/bin, I had to “sudo gem install rake” (p. 27) to update the rake version to make “rails server” happy (on p. 36).
2011-08-07 266OKFirst sentence: “…reflect DHH’s philosophy…”. What does that mean? Please enlighten me! Google not helpful…
2011-08-07DHH is one of the authors of this book, and the original author of the Rails framework itself. 88OKIm not really sure with the version of book.. well i dont really know hot to create that depot.css.. I cannot find it after i finished depot_b/db/seeds.rb.. Just wanna ask if it depot.css will be downloaded from the net?
2011-08-07Instructions at the bottom of page 84 (PDF) and page 69 (hardcopy). Additional instructions can be found in the 'How to Read this book' in the Introduction. 78TYPOmapped to a database tablewhose….
—-> No space between “table” and “whose”
2011-08-07 350SUGGESTThe distance_of_time_in_words helper (first formatting helper example) is called with Time.now and Time.local(2010, 12, 25) as arguments. Same arguments are used in time_ago_in_words (the fourth example) is called with Time.local(2010,12,25), and it calls internally distance_of_time_in_words adding a Time.now as second parameter. However, the first output is supposed to be 5 months while the fourth is 3 month. I suggest that it should be the same because this can lead to a misconception.
2011-08-25 58TYPOSecond-last paragraph: ‘aset of elements’ should be ‘a set of elements’
2011-08-25 109SUGGESTGoing from 3.0 to 3.1 in Agile Web Development with Rails 3.1
In your gemfile:
gem ‘sprockets’, ‘2.0.0.beta10’ # this is a Rail 3.1.0.rc4 dependency
This allows the CSS to load without problems. I tracked this down after a couple hours; it doesn’t look very common. It may be fixed in future versions but as of 8/14/2011 it needs to be fixed manually.
In the seeds code
Change ‘/images/image_name.jpg’ to ‘/assets/image_name.jpg’ because of the assets pipeline in Rails 3.1.
(dated: 8/14/2011)
2011-08-25 233TYPOWhile we are here, we should attend to two other things.
But only the first one mentioned in the book.
2011-08-25 152SUGGESTThe code snippets for the
when the ‘select * from line_items’ is run after placing an order, the output from sqlite returns a row with a column ‘price = 49.5’. The price column isn’t part of the initial create or added subsequently - maybe I’ve missed it, but I can’t find it anywhere?
2011-08-27 169OKPlease ignore my previous comment about price, it’s added as part of the playtime exercise (as stated in the following paragraph - doh!)
2011-08-27 146ERRORThe Ajax magic section found on pages 145 to 146 creates the appropriate display in all tested browsers except IE 9. Tested browsers include: Opera 11.50, Firefox 3.6.13, and Chrome 13.0.782.215. The problem with the functionality in IE 9 is that the cart item is added twice to the cart itself: everytime an item’s add button is pushed, it adds the item to the cart twice (maybe something to do with the DOM event handler?) Don’t know if this is a known bug with IE and/or Rails or not.
2011-08-29Retested with Rails 3.1 (and therefore, JQuery) and IE9, and saw no problems. Thus, consider "fixed" in the upcoming version that covers Rails 3.1. 71ERRORSo it seems that you didn’t update any of your code downloads to include rails 3.1 applications……no asset directory in any of the code…..therefore….no images available where your pdf links take us, nor in the code downloads…..probably no scss files also….
2011-09-01 71ERRORSeeds.rb still has /images/image.jpg in all urls…..need to delete the leading /image directory……
2011-09-01 377ERRORCode sample for product.rb is missing reference ot fresh_when
2011-09-05Code sample should have been the following: \n \ncode/rails31/depot_u/app/controllers/store_controller.rb 74SUGGESTChapter 6. Task A: Creating the Application" of the PDF version
He shows the contents of <application.html.erb>. And, he is trying to indicated that the file should be edited and the following code should be added,
Generally, when this is the case there is a “bullet” prefixed on the line that needs to be changed/added. But here i don’t see that and it looks as though that piece of code is already part of that file.
2011-09-05 71TYPOlink for ….code/depot_b/app/assets/images should actually be:
….code/rails31/depot_b/app/assets/images/
2011-09-01 72OKThe code zip for Rails31 doesn’t have all of the images for the seed file. Also hashes are specfied as :key ==> value versus key: value.
2011-09-01Did you look in the rails31 directory? Unzip and look at rails31/depot_b/db/seeds.rb. It should match the following http://media.pragprog.com/titles/rails4/code/rails31/depot_b/db/seeds.rb 113TYPOSmall typo
The first line references:
“app/controllers/line_items_con-troller.rb”
instead of:
“app/controllers/line_items_controller.rb”
I’m reading on Kindle - location 1687 code for rails31/depot_b/app/views/products/index.html.erb
The
tag needs to have a class of “products” to match up with the CSS file created in the previous page.
2011-09-05 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
72 | TYPO | and connection these rules to the to the page by defining an HTML class | 2011-09-05 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
71 | ERROR | The link for the seeds.rb file works, but it seams to be the wrong one. | 2011-09-03 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
66 | 66 | OK | In the migration, Shouldn’t it be: | 2011-09-03 | See "Choosing a Ruby version" on the top of PDF page 4. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
300 | ERROR | In Figure 47 (Sequence of Active Record callbacks) the operations“update operation” and “insert operation” are interchanged. | 2011-09-05 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
152 | TYPO | In the last paragraph: | 2011-09-05 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
71 | ERROR | Link at bottom of page is wrong | 2011-09-03 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
176 | TYPO | The code for “script/load_order.rb” is neither provided nor linked to . | 2011-09-05 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
177 | SUGGEST | The <%= will_paginate to #… | 2011-09-05 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
71 | TYPO | Seeds.rb file: The apostrophe in “Javasript’s”, line 14 is giving an error. invalid multibyte char (US-ASCII) | 2011-09-03 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
251 | TYPO | “InChapter 3” needs a space | 2011-09-05 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
95 | 75 | OK | rails31/depot_b/app/views/products/index.html.erb tag should be which includes the total. Setting the value to less than 1 seems to solve the problem entirely.
|