By Developers, For Developers

Historical errata for Agile Web Development with Rails 3.2

PDF PgPaper PgTypeDescriptionFixed onComments
11TYPO

“significantltly refactored” s/b “significantly refactored”

2010-04-14
26TYPO

Seems that rails 3.0.0.beta3_ —version should be rails 3.0.0.beta3 —version on line 4

2010-04-14
63TYPO

“YAML is used as convenient way…” should be “YAML is used as a convenient way…”. An “a” should be added.

2010-04-14
25TYPO

The text at the beginning of this page, “develop this book so that you can be absolutely confident that the output and examples exactly match”, doesn’t make sense as a continuation of the sentence at the end of the previous page.

2010-04-14If you look real close, you will see the very tops of some characters at the bottom of page 24. The obscured text is as follows: \n \n[For example] ... you might want to run the version of Rails that matches this version used to ... [develop this book so that you can be absolutely confident that the output and \nexamples exactly match.] \n \nThis will be corrected in the next beta.
133ERROR

At this page We are expecting to get the cart list showing the total price. But its not showing any out instead at this moment we are getting an error because the total_price function for particular book is not defined means error at line number 7 of show.html.erb file under views of carts. Cause you people forget to add

def total_price
product.price * quantity
end

function in line_item.rb file.

2010-04-15
48TYPO

Third sentence in second paragraph reads: “It also asks
the model to find the information for product 123.”
The example you are using uses id = 2.

2010-04-15
49TYPO

2nd line on page: “choses” should be “chooses”

2010-04-15
18OK

under Ruby Tips
‘Although you need to know Ruby…’
should read
‘Although you do not need to know Ruby…’

2010-04-16You do need to know Ruby to write Rails applications, and that's why this book includes an introduction to Ruby.
96TYPO

Third paragraphy after Text Fixtures heading. Second sentence reads: “These files contain
test data in either comma-separated value (CSV) or format.”
Should be “(CSV) or YAML format.”

2010-04-16
44TYPO

Extra >’s at the end of the lines:
– Concatenation: <%= “cow” + “boy” %>>
– Time in one hour: <%= 1.hour.from_now %>>

2010-04-16
97TYPO

The product listed in depot_c/test/fixtures/product.yml has a title of Title One.

On the first line of page 98 it is referred to as the Ruby book and again on the first line of the second paragraph of page 99

2010-05-08
24TYPO

The sentence continuing on to page 25 is missing something. Looks like the red banner at the bottom of 24 might be obscuring a line of type.

2010-05-03
26SUGGEST

“See on page 221” should be just “See page 221”

2010-04-20
64TYPO

which inherits from the Migration class from the ActiveRecord “module”

2010-04-20
132ERROR

In order for total_price method to work I had to move it from the cart model to the line_item model

lass LineItem < ActiveRecord::Base
belongs_to :product
belongs_to :cart

def total_price
@line_items.to_a.sum { |item| item.total_price }
end
end

2010-04-20
109TYPO

The command on the final line should be ‘rake test’ not ‘rake tests’.

2010-04-20
83TYPO

In the printout of “depot_b/app/views/layouts/application.html.erb”, the line:
<%= stylesheet_link_tag :all, ‘depot’ %>

Has depot listed as the stylesheet name, but we haven’t changed it yet. It should have the stylesheet name of ‘scaffold’ still, or:

<%= stylesheet_link_tag :all, ‘scaffold’ %>

2010-04-23Two paragraphs above this point, the depot stylesheet should have been downloaded. I've updated the text to make this clearer.
35TYPO

“SayController is an class” should be “a class”

2010-04-20
147ERROR

You are adding this line of code
<% unless cart.items.empty? %>

But there is no such thing know as items in cart. We are having line_items in a cart,So this must be
<% unless cart.line_items.empty? %>

2010-04-20
11SUGGEST

There’s no indication of who wrote the main part of the Acknowledgements, just the pieces from Sam and Dave.

2010-11-20
115TYPO

At the end of the first line it should be ‘a cart’ not ‘an cart’.

2010-04-20
117TYPO

I might be getting a bit over zealous here but, in the last paragraph it states ‘All we need to modify is two lines of code’ which is correct but we also need to add two lines of code as well.

2010-04-20
126TYPO

In the final paragraph it says ‘giving it a product id of wibble’, this should be ‘giving it a cart id of wibble’

2010-04-20
127TYPO

Third paragraph refers to ‘bad product ids’ should read ‘bad cart ids’

2010-04-20
28SUGGEST

I think BBEdit is worth mentioning alongside TextMate. Version 9 implemented a lot of the features listed on pp. 27-28.

2010-11-10
65TYPO

Second line on page: “easy of authoring” probably should be “ease of authoring”. However, that phrase also sounds awkward.

2010-04-20
44TYPO

Extra brackets at end of bullet 2 and 3 under ‘Playtime’

2010-04-20
94SUGGEST

Instead of using !product.valid?, IMHO I think using product.invalid? is more descriptive.

2010-04-20
103OK

Should also remove /images/rails.png file as it’s not used anymore.

depot> rm public/images/rails.png

2010-05-03
166ERROR

The output shown on this page is not working cause you forget to add a relationship in order model ie order.rb

Here it is
has_many :line_items

2010-04-24
43TYPO

“Constructed a toy application showed us the following:” change to “which showed”

2010-04-20
123SUGGEST

Please remove line 3 of line_items_controller.erb
That is
product = Product.find(params[:product_id])
as it’s no longer used

2010-04-20I changed it so that product is used... and thereby prevening bogus product ids from being added to the cart.
131SUGGEST

Should use one consistent of store_url or store_path for both redirection code of carts_controller and functional test of carts_controller.

2010-04-20Actually, there is a reason why it is done this way, and the next beta will include an explanation from DHH. Short version: use _url for redirect, and _path for link.
132ERROR

Missing total_price function for LineItem model

class LineItem < ActiveRecord::Base
belongs_to :product
belongs_to :cart

def total_price
quantity * product.price
end
end

2010-04-20
97ERROR

class ProductTest < ActiveSupport::TestCase
fixtures :product
end

Should read:
class ProductTest < ActiveSupport::TestCase
fixtures :products # products not product, plural
end

2010-04-20
132ERROR

I do not think that we should use instance var @line_items here, instead we should change it to line_items.

def total_price

  1. @line_items.to_a.sum { |item| item.total_price }
  2. become
    line_items.to_a.sum { |item| item.total_price }
    end
2010-04-20
64TYPO

3rd Paragraph, 3rd line : ‘modeule’ should be ‘module’

2010-04-20
142TYPO

In the second code block, missing the change indicator triangle for the format.js line

2010-04-20
143TYPO

The first troubleshooting hint is ‘Did you delete the old create.html.erb file’. I can’t see where it was created earlier.

2010-04-20
147SUGGEST

I’d be great if you could explain when to use instance_var and local_var within a model. That is, why we use line_items instead of line_items within cart.rb

2010-04-21This is a case where I shouldn't have used the instance variable, and that will be fixed in the next beta. The discussion as to why appears on page 177 in the current beta.
73TYPO

In the gray box, ‘A “magic” commands worth knowing…’, “commands” should be “command”.

2010-04-20
40SUGGEST

Re: Bullet #5, “Rails processes this template through Erubis,…” ERubis is only mentioned this once, other than the Rails dependency list. The rest of the book only talks about Erb (ie p. 38), so the mention of ERubis with no explanation was surprising. Would something like “ERubis (a fast Erb engine)” be good here?

2010-04-20Switched to simply ERb.
149ERROR

In the source file, I found depot_o but starting from page 149 the source code skip depot_o straight to depot_p? So isn’t there any depot_o?

2010-04-25
151OK

This bug is similar to #42843. Again, does Tests rules follow the same rule store_path for link and store_url for redirect?

assert_redirected_to store_path
OR
assert_redirected_to store_url

2010-05-03
156SUGGEST

I think newbies would ask why we have ‘return’ line in controllers/orders_controller.rb.

2010-04-24
83OK

depot_b/app/views/layouts/application.html.erb should be
depot_b/app/views/layouts/products.html.erb

2010-04-22Are you sure you are running beta3? This changed from Rails 3.0.0.beta2 to beta3.
163ERROR

In the line_item.rb source code of the end of 163 and beginning of 164, if I understand the context correctly, the GREEN ARROW should point at line belongs_to :order instead to show this line is newly inserted and relevant to the whole context of order and line_item association.

2010-04-24
165ERROR

Figure 12.3 does not reflect the code. It’s seems to be the one of Rails book 3.

+ There is no CSS rules for #errorExplanation in our depot.css
+ No style_link_tag to scaffold in application layout anymore for #errorExplaination CSS
+ And there is no line ‘There were problems with the following fields’ anymore

2010-04-24
159ERROR

Missing CSS style for #errorExplanation, #errorExplanation h2, #errorExplanation ul li, .fieldWithErrors

2010-04-24
83SUGGEST

In page 83, you’ve already given the source code of application.html.erb, I think we don’t have to repeat the source code in the beginning of page 84.

2010-04-23
106ERROR

In the whole book makes no reference to application.css file so I believe we do not need the line <%= stylesheet_link_tag “application” %> in application.html.erb at all.

2010-04-22
106SUGGEST

I am not sure if this is a mistake or not but the source no longer use the scaffold.css as indicated in the line <%= stylesheet_link_tag “depot”, :media => “all” %> so I think we should tell readers to remove scaffold.css.

2010-04-23Actually, beta three changed from application.css to scaffold.css, and this example needs to be updated.
165ERROR

page[:notice].hide for create.js.rjs does not work. The notice has only CSS class and lacks HTML ID.

2010-04-24
167ERROR

Same bug with #42870, both code refer to notice div with ID=“notice”. I think the fix would be add ID to div notice…

2010-04-24
167ERROR

Missing routes for who_bought function

resources :products do
get :who_bought, :on => :member
end

2010-04-25
0ERROR

Product model has duplication of line has_many :line_items from depot_p onward

2010-04-21
169ERROR

After adding the routes for who_bought, The atom curl part is using wrong uri, it’s supposed be /products/3/who_bought.atom

And to make it work, we need to modify the Product model to have:

has_many :orders, :through => :line_items

2010-04-24
163SUGGEST

Lack explanation on the usage of :touch => true syntax.

2010-04-24Removed the use of :touch
0SUGGEST

For consistency, every iteration should have show git commit command.

2010-05-05I'm concerned that that would end up being repetitive. I've added a reminder in chapter 8 as well as a pointer to chapter 16 where additional git functionality will be explored.
82TYPO

The word “download” is missing from: “…, you might want to the file fom the sample code available online.”

2010-04-22
162ERROR

At this iteration, rake test still fail with 2 failures:

1) Failure:
test_should_create_order(OrdersControllerTest) [test/functional/orders_controller_test.rb:30]:
“Order.count” didn’t change by 1.
<3> expected but was
<2>.

2) Failure:
test_should_update_order(OrdersControllerTest) [test/functional/orders_controller_test.rb:49]:
Expected response to be a <:redirect>, but was <200>.
Expected block to return true value.

They are both due to our Order fixture is bad. here is my example fixture that pass the test

one:
name: Whyte House Productions
address: 4 Upton Rd
email: trung.le@whytehouse.com.au
pay_type: Check

2010-04-25
51TYPO

“and will seeing and modifying” should be “and will be seeing and modifying”

2010-04-22
51TYPO

“start with the Product Controller on Section 8.1,” should be “starting with the Product Controller in Section 8.1” (note two changes)

2010-04-22
52TYPO

“(and for some you,” should be “(and for some of you,”

2010-04-22
160OK

Why don’t we add Order’s validation for email format? It’s very common that beginners will bump into such validation.

2010-11-10
158ERROR

It’s seems to me that the View code for new order form should be in _form.html.erb partial NOT new.html.erb.

2010-04-24
163SUGGEST

Why do we have to set line_item.cart_id to nil?

item.cart_id = nil

2010-04-24So that the the line item doesn't get destroyed when the cart gets destroyed. This will be explained in the next beta.
163ERROR

The same as #42840, but I think the association deceleration should be on page 163

2010-04-24
145SUGGEST

There is no change in the cart.rb code. We are already returning the LineItem object from the original code we created on page 123

2010-04-23
146TYPO

the create.js.rjs code block is missing the change indicator triangle for the code

2010-04-23
147OK

the create.js.rjs code block has 2 change indicator triangles when only 1 is needed

2010-05-03The blank line is also new
149TYPO

the carts_controller code example doesn’t remove the message from the flash as the text above it suggests

2010-04-24
9TYPO

Looks like this sentence was rewritten:

“In the process, Rails has become mainstream,
and therefore attracted a more diverse set of developers have been attracted to
the framework.”

2010-04-22
93TYPO

Super minor nit: The book has “ls test/unit” printing “product_test.rb”; I got “helpers product_test.rb” (using Rails 3.0.0.beta3).

2010-04-23
53TYPO

“And object is a combination of state” should be “An object…”

2010-04-23
95ERROR

In the “image url” test, the second argument to both asserts might be a leftover from code copied from another test: The first assert has the message argument “product.errors.full_messages,” which does not indicate which name caused the failure. The second assert has the message argument “saving #{name}”, but the test is not saving anything.

2010-04-23
47TYPO

Para 3, last sentence:
‘an resource’ should be ‘a resource’

2010-04-23
100TYPO

the git command, git commit -a -m “Validation!”, returns the following error: -bash: !": event not found

The solution seems to either remove “!” or put it immediately after the second double quotes (first time using git, so I’m not sure about the meaning of the returned message…event? what event?)

2010-04-23Seems to work better with single quotes.
49TYPO

First code example should probably show $ with the amount. So it should be as follows:

order = Order.find(1) puts
puts “Customer #{order.customer_id}, amount=${order.amount}”

2010-04-23
52SUGGEST

Maybe not errata - but suggested for voice and to fix one typo:

Instead of:
There’s a lot to Rails. But before proceeding onto writing something more substantial lets have a brief refresher (and for some you, an brief introduction) to the Ruby language itself.

How about:
There’s a lot to Rails. But before going any further let’s have a brief refresher—and for some of you, a brief introduction—to the Ruby language itself.

2010-04-23
54TYPO

In the description of method calls - should be plural form:

Should be: Parentheses generally are optional in method calls.

Ideally reordered to be:

“Parentheses are generally optional in method calls.”

2010-04-23
97ERROR

The definition of “class ProductTest…” depicts it as a complete, three-line definition, but actually the student is adding a line to an existing (and by now pretty beefy) class. The “this line added/changed” icon would be good here.

2010-04-24
116TYPO

A hook method is a method that Rails calls automatically at a tiven point in an object’s life.

tiven should read given

2010-04-24
103TYPO

In the sentence “Let’s simply things for the user…”, the word “simply” should be “simplify”

2010-04-24
118TYPO

at a tiven point => at a given point ?

2010-04-24
102TYPO

“we will also need compliment” is missing the word “to.”

2010-04-24
103TYPO

In “We’ll leave these lines along,” “along” should be “alone.”

2010-04-24
109SUGGEST

“rake test” actually fails validation if the student writes the Playtime code for the previous chapter to add validation on title length >= 10 characters. Tests such as test_product_is_not_valid_without_a_unique_title fail because the the title of the product fixture, Title One, is < 10. To avoid possible confusion, you may consider replacing the title with something longer.

2010-05-08
59OK

I’m baffled by the two examples of blocks appearing after calls to methods:

greet { puts “Hi” }

and

verbose_greet(“Dave”, “loyal customer”) { puts “Hi” }

These functions are never defined, so the examples and the proceeding explanation about “yield” are just confusing. I would strongly recommend defining greet and verbose_greet, with meaningful yield functionality.

2010-11-10
117ERROR

I might be wrong, as I haven’t run it yet, but
<%= button_to ‘Add to Cart’, line_items_path(:product_id => product) %> should rather be <%= button_to ‘Add to Cart’, line_items_path(:product_id => product.id) %>
that is, product.id rather than product

2010-07-24Explained that you can pass in product as rails will extract the id.
111SUGGEST

The description of the assert_select functional test reads:

“So the first select test looks for an element named a that is contained in an element with an id with a value of side which is contained with an element with an id with a value of columns.”

It should probably read (changed a ‘with’ to ‘within’):

“So the first select test looks for an element named a that is contained in an element with an id with a value of side which is contained within an element with an id with a value of columns.”

2010-04-25
65TYPO

At the top of page - in the sentence “like optional parenthesis and braces, contribute to the overall readability and easy of authoring.”

1. ‘parenthesis’ should be plural ‘parentheses’
2. ‘easy’ should be ‘ease’

2010-04-27
66TYPO

in description of lambda: “used in on page 222”. Remove “in”.

2010-04-27
9TYPO

“therefore attracted a more diverse set of developers have been attracted to the framework” — duplicate predicate

2010-04-25
24ERROR

I found it very helpful to have irb and sqlite3 (the command-line client) available. I think you should add these 2 packages to the list of Ubuntu packages that users should install.

2010-05-01
152TYPO

Under what we just did section:
• We used :remote => true to invoke the LineItemnew action using Ajax.

Should read:
• We used :remote => true to invoke the LineItem.new action using Ajax.

2010-04-27
23TYPO

I would suggest to introduce the using of rvm Ruby Version Manager for Mac OS X, specially using Named Gem Sets for rails 3

2010-05-05I've added it to the todo list for part 3. I'm a big fan of rvm, and use it extensively myself on both Linux and OSX. However: my experience is that it is still evolving rapidly, and beyond the basics needed to get up and running quickly.
29SUGGEST

Maybe mention RubyMine JetBrains Rails IDE will be worth

2010-04-27
30OK

Mention railsapi.com as an option for online and offline api documentation maybe will be nice

2010-07-24
33OK

Maybe here is much better introduce bundler for install the Required Gems rather to use in page 22 gem install sqlite3-ruby

2010-05-05My feeling is that once you are up and running, bundler is the way to go, but on initial install it represents one more thing to debug and may possibly obscure the real error.
35OK

I do not want to sound purist, but the “Hello World” demo app is almost the same as First Edition. Since REST architecture adoption for Rails Apps seems to me that Demo should be rewritten from scratch to be RESTful and showing better the current Rails practices. Maybe a good idea will be to have a i18n “Hello World” using a RESTful architecture and TDD o even better BDD. Also for beginners will be better to have the first Rails contact using the best practices. Maybe showing also the use of git for VCS

2010-05-05The primary purpose of this application is an installation verification test.
178SUGGEST

Provide explanation on self.class and class << self syntax.

2010-11-10
47OK

Maybe the best way to express the URL is my.url/products/2/line_items sending a POST to the nested resource line_items

2010-11-10
182ERROR

the <%= f.error_messages %> doesn’t display error messages anymore

2010-04-27
182ERROR

Should not hard code button caption in <%= f.submit “Add User”, :class => “submit” %> because if you do, when you edit a username, the button still shows ‘Add User’ instead of ‘Update User’. The fix is trivial, use <%= f.submit %>

2010-05-01
60TYPO

the sentence “to pass a Proc as a block” could be confusing for beginners because Proc has been not defined yet. Maybe an explanation about Closures and explaining that Blocks are not objects, but they can be converted into objects of class Proc will clarify this.

2010-05-05Removed the mention of the word "Proc" as it isn't necessary to the understanding of the Rails.
183ERROR

For @input_attributes, should we use symbol instead of string?

2010-07-24
66OK

Because relies in Ruby Metaprogramming maybe will be good to have a section about definition as “Metaprogramming is writing code that manipulates language constructs at runtime” explaining briefly open classes, the method lookup, self, and method_missing

2010-05-05There certainly is a lot to Ruby that this brief introduction doesn't cover, but none of the above is directly related to the tasks discussed in the book. Except self, which is covered on page 61.
69OK

Why not use User Stories, Features and Scenarios rather than Use Cases? That will allow also to introduce practices as TDD/BDD from the beginning easily IMHO

2010-05-03The intent of part II is to introduce developers to Rails as it exists. Part III will describe other alternatives, such as Cucumber and RSpec.
70OK

Maybe will be worth to mention tools for sketching web sites as DENIM from University of Washington dub.washington.edu:2007/denim/

2010-05-11
96OK

Maybe will be worth a discussion regarding fixture shortcomings because they are external dependencies which can make tests brittle and difficult to read. And mention their replacement using Test Data Builders which give us a centralized mechanism we can use to construct objects in code examples, allowing the test examples to be very explicit about what is needed (or not needed) for a particular behavior. Without to scan through multiple files to understand an example.

2010-05-05The purpose of Part II is to document features of Rails, not to criticize them or to suggest alternative.
153SUGGEST

I received undefined method when using the suggested form_remote_tag in the first playtime task. I got it to work using form_for with the :remote => true parameter.

2010-04-27
117TYPO

The text reads:
" … the directive is fairly self-explanatory: an cart
(potentially) has many associated…"

I think it should be:
" … the directive is fairly self-explanatory: a cart
(potentially) has many associate

2010-05-01
118TYPO

Text reads:
“A hook method is a method that Rails calls automatically at a tiven point in an object’s life.”

I think it should be:
“A hook method is a method that Rails calls automatically at a GIVEN point in an object’s life.”

I’m only reading the chapter 9. (I don’t have the full book) or the beta version.
But I hope this helps
;^)

2010-04-27
114OK

We can argue based on the responsibilities for each component that the method “find_or_create_cart” should be defined in the Cart Model as a class method rather than a private method for the ApplicationController. The session[:cart_id] could be a parameter for the Cart.find_or_create. This will be more expressive regarding the intention

2010-05-01That would violate MVC: sessions are a controller concern.
116TYPO

Once this decision is made, the rest follow => should this be ‘the rest follows’ or ‘follows on’ ?

2010-05-01
119ERROR

Before editing carts/show.html.erb “Line item was successfully created.” will appear twice

<%= notice %>

appears at the top of default view created and there is also a call to display the notice in the application layout

2010-05-08
124SUGGEST

For discussion will be rather than using “LineItem.where(:cart_id=>cart).group(:product_id).sum(:quantity)” use “cart.line_items.group(:product_id).sum(:quantity)” also for the “LineItem.delete_all :cart_id=>cart, :product_id=>product_id” replace with “cart.line_items.delete_all :product_id=>product_id”

2010-05-01
89OK

Not sure why, but “validates” does not work. “validate” does.

2010-05-01I've tested the code, and validates is correct: \n \nhttps://rails.lighthouseapp.com/projects/8994/tickets/3058-patch-sexy-validations
150TYPO

Since this error represent the majority of the problems reported => Since this error represents the majority of problems reported

2010-05-01
171TYPO

Will this in place => With this in place

2010-05-01
171SUGGEST

Should the line bundle install be given the same formatting as other command line instructions eg.

depot> bundle install

2010-11-10
51SUGGEST

Drop the discussion whether Erb is good or not. Calling people who don’t agree with you ‘purists’ and dismissing their arguments is bad form in my view.

2010-05-01Removed 'purist', added prose suggesting that code in views is not something that should be overdone.
93SUGGEST

I’ve been using RSpec the last couple of years, so I might be missing something, but I don’t recognize the ‘test … do’ format. Looking at the web docs for Test::Unit it still uses ‘def testXYZ’. Perhaps point that out.

Also - RSpec is one reason not to use Test::Unit as an answer to the question “and why wouldn’t we be”

2010-05-07
50ERROR

“the Rails views can extract and format errors with just a single line of code” — not true anymore, the methods got pulled out into the dynamic_form plugin.

2010-05-01
53TYPO

I believe “Welcome to the Ruby community.” should end in an exclamation mark (!)

2010-05-01
97TYPO

It should read ‘:products’, not ‘:product’

class ProductTest < ActiveSupport::TestCase
fixtures :products
end

2010-05-05
114OK

I was seeing multiple carts being created until I modified the “create” method of CartsController, which was created by the scaffolding.

def create
@cart = Cart.new(params[:cart])

end

Turned into:

def create
@cart = find_or_create_cart

end

2010-06-28Can't reproduce
39TYPO

Maybe mentioning that are alternatives for Erb will worth. You can use the excellent ruby-toolbox.com/categories/template_languages.html

2010-05-05Part II is for describing what is included in Rails. Part III is for replacement parts. I've added this to the list of things to cover in Part III.
52OK

Mention than the current best practice for controllers is to have a RESTful architecture. Maybe explaining here about the uniform interface, the resources, http methods, nesting resources, the formats to respond, and routes> I know this imply profound changes in the section, but REST has several years in the mainstream of RoR then IMHO it is imperative to have in this book. Restful is only mention on page 15. I know that you have an stub in page 235 for Rails Concepts, but I insist that an earlier introduction about REST architecture is a must

2010-07-24This book is very intentionally layered... just enough theory to provide needed context, then a lot of actual use, finally followed by a description of the actual components, with the theory behind them.
53OK

Well, it is true that Ruby Is an Object-Oriented Language but will be worth to mention that is multi-paradigm including functional, object oriented, imperative and reflective. It also has a dynamic type system and automatic memory management. I know this is a gentle introduction for beginners but the functional and reflective paradigms are important for some RoR constructs, then a mention about this will be worth IMHO

2010-05-11I'm just trying to cover enough Ruby to make the examples which are contained in the book comprehensible. If you see a specific feature of Ruby that is actually used in the book that requires explanation, please create specific errata on such features.
69OK

I will insist that IMHO the intent for the section and the spirit for an Agile Software Development book is more related with User Stories rather than Use Cases. As you know Use Cases have an special connotation since Ivar Jacobson work and refined as a technique specially in the work of Alistair Cockburn. As it is mentioned in wikipedia a use case in software engineering and systems engineering is a description of a system’s behavior as it responds to a request that originates from outside of that system. In other words, a use case describes “who” can do “what” with the system in question. The use case technique is used to capture a system’s behavioral requirements by detailing scenario-driven threads through the functional requirements.
A user story is a software system requirement formulated as one or more sentences in the everyday or business language of the user. User stories are used with Agile software development methodologies for the specification of requirements (together with acceptance tests).
Andrw Stellman has an interesting post about User Stories vs Use Cases in www.stellman-greene.com/2009/05/03/requirements-101-user-stories-vs-use-cases/
Mike Cohn in his book “User Stories Applied: For Agile Software Development:” mentioned some advantages about User Stories:

  • User stories emphasize verbal rather than written communication.
  • User stories are comprehensible by both you and the developers.
  • User stories are the right size for planning.
  • User stories work for iterative development.
  • User stories encourage deferring detail until you have the best understanding you are going to have about what you really need

Now in the BDD practices they are using Feature as a high level requirement expressed from the perspective of a person or another computer using the system. Those are similar an a User Story but additionally include automated scenarios that serve as acceptance criteria, expressing each feature in the Connextra Format and their scenarios as steps for: Given, When, Then

I am sure you are aware about all these an even more, but my point is that the book should express or mention this.

2010-05-11Let's continue this discussion on the forums: http://forums.pragprog.com/forums/148/topics/4372
70OK

Maybe mention the Paper prototyping method from human–computer interaction will be worth

2010-07-26
78ERROR

The output from rails server is outdated, as it is mentioned on page 22 RoR requires Ruby version 1.8.7 and this output shown [2008-03-27 11:54:55] INFO ruby 1.8.6 (2007-09-24) [i486-linux]

2010-05-05
81OK

Because this book will be read also by beginners IMHO, best practices should be presented and enforced then rather to put the Unit Testing in Iteration B2 I will suggest to put in iteration A2. In the same line is not clear for a beginner how do you transitioned from the User Story or Use Cases ;-) to the implementation.

2010-05-11Doing test first development would nearly double the size of the book, and would dilute the focus on Rails. If you look closely, we are only writing tests for a fraction of the functionality, and fixing only slightly more than absolutely necessary in the generated tests. At the end of part II, I plan to explain that while this exposes you to the necessary concepts of testing as provided by the Rails framework (namely: unit, functional, and integration testing), it is incomplete.
89OK

Again, maybe will be worth to write the unit test before than the validation. This to enforce the TDD/BDD cycle as a recommended practice

2010-05-05See #43067
94SUGGEST

To be consistent with the full test change assert !product.valid? to assert product.invalid?

2010-05-05
107SUGGEST

Maybe will be useful put a Ruby tip for yield to page 59

2010-05-05
114SUGGEST

The find_or_create_cart name IMHO is not appropriate for the domain of the application, I’ll suggest current_cart which emphasizes the domain intention for the method that is to have the current_cart for the session. If the current_cart does not exist creates a new cart if the cart exist returns the current cart after finding it by id

2010-06-19
115SUGGEST

In this stage the before_destroy :ensure_not_referenced_by_any_order filter could be renamed to before_destroy :ensure_not_referenced_by_any_line_items to reflect better the current intention. I know that later the Order domain objet will be included and defined as a set of line_items along with details of the purchase transaction. But that is not defined yet. And will be good to refactor the filter to renamed once the Order domain object will be included in the application

2010-05-07
123OK

IMHO the line current_item = line_items.where(:product_id => product_id).first
should be rewrote to current_item = line_items.find_by_product_id((product_id) but either way is correct

2010-05-08That hasn't been explained yet
110TYPO

“provides” should be “provided”
Paragraph in middle of page reads:
“The test provides gets …”
should read:
“The test provided gets …”

2010-05-05
149SUGGEST

Maybe worth to put a Ruby tip call for &block notation to page 59

2010-05-07
152OK

The Test First in TDD/BDD actually are more about to define the desired behavior written the failing test using The Code You Wish You Had this will provide you with an emerging design. Usually this is better if you use an outside-in approach where Business Value drives the development. Then you code The Code You Wish You Had to pass the test/scenarios and refactor and pass the test/scenarios.

2010-07-24
156SUGGEST

If you follow my previous suggestion for renaming find_or_create_cart to current_cart the line of code if find_or_create_cart.line_items.empty? will be more terse if current_cart.line_items.empty?

2010-06-25
173OK

As a suggestion for readers maybe will be worth to mention gems populator and faker

2010-07-24
209OK

Maybe mention the main gems/plugins for Rails Authentication ruby-toolbox.com/categories/rails_authentication.html will be worth

2010-07-24
231OK

For the deployment of the depot application are you considering to mention other Deployment Automation tools? Vlad, moonshine, etc.

2010-07-25
235OK

You should open the scope for TDD covering also BDD

2010-07-25
235ERROR

You are mentioning CI (Continuous Integration) in both sections. This is intentional?

2010-05-08
142TYPO

Typo is add is a call

What we are going to do is add is a call to respond_to telling it that we want to respond with a format of .js.

2010-05-07
82OK

I downloaded all source code examples for the book and when I go to run “rake db:migrate” in depot_a or depot_b (at least, I haven’t tried others yet) I get:

(in /tmp/depot_b)
rake aborted!
uninitialized constant Rake::RDocTask
/tmp/depot_b/Rakefile:7
(See full trace by running task with —trace)

I compared your Rakefiles to one that I generate using Rails3.0.0beta3 and I noticed that you are missing the following two lines from your Rakefile:

require ‘rake/testtask’
require ‘rake/rdoctask’

Those two lines appear right below “require ‘rake’”

I don’t know if I have a special environment or if you have outdated Rakefiles. Just wanted to notify you.

Awesome book! Thanks!

2010-05-07I'm actually developing using the latest (unreleased) Rails. This will work itself out as new betas of Rails are released.
122TYPO

“adding a one or more columns” should read “adding one or more columns” in the sentence that starts:
“Rails can tell from the name of the migration…”

2010-05-07
123OK

Tighter code for add_product:

current_item = line_items.where(:product_id => product_id).first
current_item ||= LineItem.new(:product_id=>product_id, :quantity => 0)
current_item.quantity += 1
line_items << current_item
current_item

Also, the code might be more intuitive and prettier to use product instead of product_id.

2010-05-08While that code is unquestionably tighter, I believe it is more difficult for somebody new to Ruby to understand.
127OK

The error screenshot is misleading. In production, the error screen is much nicer.

I think getting an error screen in response to a user-type invalid URL is a perfectly legitimate response. I don’t think you should encourage people to litter their code with validations like this, it’ll just bloat apps and make coding less fun.

Also, if you’re really keen on handling this error, I think it’s more robust to replace Cart.find with Cart.where(:id => params[:id]).first and do an if based on that value (it’ll be nil if the record doesn’t exist). This way you’re safe no matter what exception gets raised.

2010-11-10
131OK

Regarding the “David Says…” bubble — sounds like redirect_to should raise an error if the path isn’t a full URI (perhaps check that ‘:’ occurs before ‘/’?).

Why not file a bug and get this fixed, then describe it in the context of handling the exception?

2010-05-08That likely would break code that works, even if it is the code is technically wrong.
143ERROR

:partial and :object are getting out of style in Rails 3 as far as I’ve seen. How about replacing the code with

page.replace_html(‘cart’ , render(‘carts/cart’ , :cart => @cart))

2010-05-07
143ERROR

Gah, sorry, I wasn’t thinking. This would be even better:
page.replace_html(‘cart’ , render(@cart))

2010-05-07
157TYPO

You mean <%= form_for ?

2010-05-07
47TYPO

Remove the word ‘for’ from the following line.

“See Figure 3.1 for to see how the three concepts fit together.”

2010-05-07
64TYPO

2nd paragraph, 2nd line : “name” should be “named”.

2010-05-07
93TYPO

Top paragraph; “What need to do more than that” I believe should be “We need to do more than that”

2010-05-07
54TYPO

Extra period
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:

2010-05-07
81TYPO

4th Paragraph, 3rd Line : “The” should be “They”.

2010-05-07
146TYPO

bottom of the page. and no download link.

<%= button_to “Empty cart” , :action => :empty_cart %>
this is the only place I see :action => empty_cart
everywhere else it is
<%= button_to ‘Empty cart’, cart, :method => :delete, :confirm => ‘Are you sure?’ %>

2010-05-08
95TYPO

The looped block behind the bad and new array is exactly the same piece of code. Doesn’t look so DRY :-).

2010-05-07One test for valid, and the other for invalid; but you are right this can be improved.
112ERROR

The last item in “Playtime” suggests writing function tests for the product maintenance application, placing the tests in store_controller_test.rb. Should the tests be placed in products_controller_test.rb instead?

2010-05-08
119OK

“<% for item in cart.line_items %>" would be more ruby like, if it would read like this: "<% cart.line_items.each do |item| %>” . Maybe it’s only my personal preference :-) .

2010-05-08This early in the book, I'm trying to keep with things that might not look so foreign to people new to Ruby.
114OK

Says: " This makes this method only available to other controllers, and in particular it prevents Rails from ever making it available as an action on the controller."

Should say “as an action on the view”?

2010-05-12
82ERROR

I received a HTTP 403 error when trying to download images as suggested from this link:

media.pragprog.com/titles/rails4/code/depot_b/public/images/

2010-05-12Will fix in the next beta. For now, you can find the images here: \n \nhttp://media.pragprog.com/titles/rails4/code/depot_c/public/images/
202TYPO

Second to last paragraph:
“… we’ll use a before4 filter…”
Should be:
“… we’ll use a before_filter…”

2010-05-12
35TYPO

Bottom of page

Pretty minimal, eh? SayController is an class …

Pretty minimal, eh? SayController is a class …

2010-05-12
106TYPO

…layout application.html.erb, it will the layout used…

Should perhaps include “be” as in “…it will be the layout used”…

2010-05-12
111SUGGEST

I assume the fixtures shown here will be updated?

As they are now, the title of the first two items are not unique.

2010-07-24Added a note that neither validation nor functional tests directly affect pre-existing data, whether such data exists in the database or exists in fixtures.
237SUGGEST

In the deployment section, the production database is created in three steps: the mysql create database command, rake db:migrate, and rake db:seed. This makes sense for a first-time deployment, because it lets you see if you messed something up in any of the steps. However, Rails provides a Rake task db:setup, which combines the database creation, migration, and seeding steps into one step. It also uses the schema dump to create the schema rather than running the migrations in sequence, which I believe is the Rails-recommended way of creating a new database. This is probably worth mentioning.

2010-05-17
237SUGGEST

You suggest using the mysql root user for the production database. This is not a best practice, as if there are any SQL injection bugs in the app an attacker will be able to gain full control of the database. User management in mysql is a pain, but it would be helpful to explain how to create a non-superuser and grant it permissions on the database.

2010-05-17
87TYPO

“[…]This may not seem very exiting at this point, but it does mean that you are more free to experiment.[…] ”exiting" should be “exciting”

2010-05-12
64OK

3rd par. 3rd line

ActiveRecord modeule
needs to read
ActiveRecord module

2010-05-12Fixed in beta 2
69TYPO

2nd par - 2nd line

tests will ensure that application
needs to read
tests will ensure that the application

2010-05-12
83OK

<%= stylesheet_link_tag :all, ‘depot’ %>

Should read

<%= stylesheet_link_tag :all %>

Otherwise it looks exactly the same as on the next page…

2010-05-14Fixed in beta 2
105SUGGEST

“Note the use of the raw method for the description. This allows us to add HTML stylings to make the descriptions more interesting for our customers. (Note: this decision opens a potential security hole, but because product descriptions are created by people who work for our company, we think that the risk is minimal.)”

I would suggest you explain that ‘raw’ bypasses the default behavior of encoding the output, a common defense against XSS attacks. Then footnote to a site such as OWASP to let the reader study XSS attacks and security in general. Security is a topic often neglected in programming titles.

www.owasp.org/index.php/Cross-site_Scripting_%28XSS%29

2010-07-24
106OK

Routing Error to application.css, should be scaffold.css

2010-05-14I can't find application.css mentioned, either on this page or in the entire book.
121ERROR

Playtime, first bullet (making book’s image invokes create action): you really should mention that “<%= javascript_include_tag :defaults %>” should be added to the layout file or :method=>:post option will never work. Being a Rails newbie, a spent about an hour on this issue…

2010-05-25
110TYPO

In the section “Iteration C4: Functional Testing of Controllers”, The second sentence of the paragraph says:

Remembering the our experience after we added validation logic to our model, with some trepidation we run our tests again. It seems the “the our” is a typo.

Thanks,
Steven Elliott, Jr.
steven.elliottjr@me.com

2010-05-16
233OK

Phusion also runs on nginx now and has for a while - perhaps a sidenote of some sort relating to an nginx/passenger deployment?

2010-07-25
246ERROR

At the top of page 246 you print examples of how to configure the logger in Rails 3:

config.logger = Logger.new(config.log_path, 10, 10.megabytes)
config.logger = Logger.new(config.log_path, ‘daily’)

Both of these examples will cause Rails 3 to crash/fail to load (I’m using Rails 3 beta3), it looks like this is because there is no log_path method. I’ve had a quick look but I’m not actually sure how to set this now in Rails 3. Documentation is currently ropey at best!

2010-05-25This is actually changing in Rails 3. I've updated the beta, but will need to track the changes.
42TYPO

“are used , Rails applications are typically written”

remove the space after “used” so the comma doesn’t stand alone.

Cheers! Marc

2010-05-16
111TYPO

Third paragraph: “The next line verify that there are h3 elements…” should be “verifies”.

2010-05-16
112TYPO

First paragraph: “That’s a lot of verification is just a few lines of code.” Should be“… in just a few…”

2010-05-16
127TYPO

‘following page This reveals way too’

Missing a period in the last paragraph, within the snippet above.

2010-05-16
33TYPO

As we’ll see later (in on page 250), -> As we’ll see later (on page 250),

2010-05-17
38TYPO

See in Figure 2.3. -> See Figure 2.3.

2010-05-16
43TYPO

let’s take it gently for now…. -> let’s take it gently for now… (three periods, not four—ellipses don’t need a trailing period at the end of a sentence)

2010-05-16
105SUGGEST

A possible gotcha at this point …

a) remind the user to rake db:seed to reload the seed data if they need to (playtime at the end of iteration A has them potentially doing a rollback which would destroy existing data).

b) change the “validates :title, :length => { :minimum => 10 }” (potentially added in playtime of iteration B) to length => { :minimum => 9 } first otherwise the Debug It! book won’t be added when seeding.

;)

2010-11-12I've added the reminder in the Playtime section of section A. \n \nThe plans at the moment are to replace "Debug It!" with "Rails Test Prescriptions".
109TYPO

Second last line of section 8.3 reads “writing tests for all this new function” but should perhaps read “writing tests for all this new functionality”?

2010-05-25
111TYPO

“The next three lines verify our product are displayed” should be “The next three lines verify our products are displayed”

2010-05-25
112TYPO

In What We Just Did, item 3 says “Add a class method to the Product model to provide a list of items for sale.”, but in this version we used a default_scope instead. Whilst it’s essentially the same thing, this may be a little confusing. ;)

2010-05-25
112TYPO

Last bullet point says “the end of an iterations” but should be “the end of an iteration”

2010-05-25
132TYPO

Under David Says: “…but it won’t valid according to spec. ” should be “…but it won’t be valid according to spec.”

2010-05-25
79OK

The code-example in the middle of the page seems to be wrong:
“validates :price, […]” didn’t work for me, it had to be something like this:
“\tvalidates_presence_of :title, :description, :image_url
\tvalidates_numericality_of :price, :numericality => {:greater_than_or_equal_to => 0.01}”

CS

2010-05-25Are you sure that you are running Rails beta 3? What you are describing was the way this was done in Rails 2, and continues (for the moment) to work in Rails 3, but the intent of the Rails team is to deprecate those methods in favor of the validates method.
89OK

The formatting of the source-code at the bottom of page 89 is broken

2010-11-10
58TYPO

Ruby also provides a number of ways to make decisions which affect the repetition and order of in which methods are invoked.

2010-05-25
63TYPO

In YAML, indentation is important, so this defines development as having set of four key/value pairs, separated by colons.

2010-05-25
69TYPO

“Rails not only enables the creation of such tests, actually provides you with…”

2010-05-25
85TYPO

“Using this parameter is this way…”

2010-05-25
149OK

When I followed the example, the code snippet below

<%= render(:partial => “cart”, :object => @cart) %>

resulted in the following error:

ActionView::Template::Error (Missing partial store/cart with {:locale=>[:en, :en], :handlers=>[:erb, :builder, :rjs, :rhtml, :rxml], :formats=>[:html]} in view paths "

2010-06-28This would indicate that app/views/carts/_cart.html.erb is not present. This file was created on page 139.
148OK

Has the “total_items” any use besides it’s use in the “blenddown” call? Unless it hasn’t you could also use the @cart.line_items.count method.

2010-06-28That wouldn't take into account the quantity. What would work is @cart.line_items.sum(:quantity).
24ERROR

The details for installation of rails on the mac do not indicate the correct way to install rails 3.0. This results in the rest of the book not working as expected. the command:

sudo gem update rails

should read:

sudo gem update rails —pre

otherwise you get the latest stable version of rails, not the one in this book. Obviously if 3.0 is stable for the release things are correct, but for current users this is a problem.

2010-05-25
110TYPO

“Remembering the our experience after we added validation…”

2010-05-25
111TYPO

The next three lines verify our product are displayed.

2010-05-25
106ERROR

application.html.erb should also have:
<%= javascript_include_tag :defaults %>
in the head or :confirm dialogs don’t show up and the playtime which adds to cart from the picture click won’t work (as it’s doing a :method => :post)

2010-05-25
112TYPO

That’s a lot of verification is just a few lines of code.

2010-05-25
112TYPO

Bullet points in “What We Just Did” section are in various different tenses.

2010-05-25
112TYPO

Just a reminder, the end of an iterations is a good time to save your work using git.

2010-05-25
119OK

I think “line_item = cart.line_items.build(:product => product)” is supposed to read “line_item = cart.line_items.build(:product => @product)”.

2010-05-25No, it is meant to use the local variable assigned on the previous line: "product = Product.find(params[:product_id])"
206ERROR

It looks like you have wrong listing of the application layout for iteration I4: it’s admin links what should be added here, not l18n features.

2010-06-27
162ERROR

At the end of this page it talks about altering the fixtures to accommodate changes made to validation in an order, however the listing is for line_items, which are also listed later (pg165), I suspect this listing wants to be for the orders fixtures, otherwise tests will fail here..

2010-06-26
172ERROR

When working through the examples, and getting to the curl to retrieve the atom feed for orders, I discovered an omission. The code returns errors about products not containing orders.

It would seem that the necessary has_many code has not been mentioned. Looking at the example code downloads this should be added to Product.. This means that about page 165 the has_many relationships need adding in for Products

2010-06-26
260TYPO

Top of the page: “…you will need to add gem RedCloth (note: case is significant) to your Gemfile, and run gem install.” - do you mean “bundle install” instead of “gem install”?

2010-06-27
174OK

I might have missed something, but the paginate code was throwing an error as not existing until I restarted the server. If this is needed, the page doesn’t mention the need to stop the server and restart after installing the bundle

2010-07-24This should not be necessary
183ERROR

Didn’t you mean to show an example of html email here and not the text email again? Also, aren’t the templates named “order_received.text.erb” and “order_received.html.erb” instead of “order_received.text.plain.erb” and “order_received.text.html.erb” on line 7? An example of the html template could be the following (with some silly formatting to be easily tell we’re getting html email):

<code>
<p>Dear <%= @order.name %>,</p>

<p>Thank you for your recent order from <em>The Pragmatic Store.</em></p>

<p>You Ordered the following items:</p>

<table><%= render @order.line_items -%></table>

<p><strong>We'll send you a seperate email when your order ships.</strong></p>

</code>
2010-06-27
208ERROR

app/views/layouts/application.html.erb shown on this page has a lot of the i18n stuff already in it, when we haven’t learned about it until the next chapter… So it doesn’t match the file we’ve built up till now when working through the book.

2010-06-27
94TYPO

Typo: the last sentence of the first paragraph (immediately before the heading for section 7.2) should read “As for now, it is time for us to write some unit tests.”.

2010-06-19
32ERROR

Hi,

First off, thanks for the hard work on the Fourth Edition :-)

The section ‘Creating Your Own Rails API Documentation’ does not apply because we are not using Instant Rails, so at the very least please amend.

Unfortunately, when I followed the instructions I got loads of errors and the API was not produced.

Warmest regards,

Jeff Lawson

2010-06-19Removed mention of Instant Rails, but running rake doc:rails from the command line is the correct way to produce documentation. If you could, let me know what the errors you are getting by posting to the forums, and I will see if I can help further. \n \nhttp://forums.pragprog.com/forums/148
219ERROR

Near the end of the page when you say “At this point, we can see in Figure 15.3 the some actual translated text appearing in our browser window.” apart from the grammar error (i.e. “the some actual”), this isn’t true. If following along, there will be exceptions thrown at this point and the /es page won’t render because of currency conversions in number_to_currency. /en renders fine, but /es fails. If you put in the currency localisation found later (i.e. the number: section for the yml files found on pages 222-223) then it will work.

2010-11-12corrected the grammatical error, still trying to reproduce the problem reported.
220SUGGEST

On the page you say “Note that since title_html ends in the characters _html, we are free to use HTML entity names for characters that do not appear on our keyboard. If we did not
name the translation key this way, what you would end up seeing on the page is the markup itself.” Yet “add:” uses a “ñ” and doesn’t have _html on it, but it works, why?

2010-11-13
227ERROR

The changes for _form.html.erb shown here were already shown on page 225. They should probably be removed from the version on p. 225 to give the expected results in the figures.

2010-11-13
229OK

After fixing up the error strings for :es, the English ones were no longer correct, I had to add a lot of the activerecord: and errors: sections into en.yml also for the English path.

2010-11-13
229OK

forgot to paste in the en.yml changes I made:

activerecord:
models:
order: “order”

errors:
template:
body: “There were problems with the following fields:”
header:
one: “1 error prohibited %{model} from being saved”
other: “{count} errors prohibited this{model} from being saved”

2010-11-13
227SUGGEST

The figure doesn’t match what the code says. The whole error box looks different (i.e. lacks the ‘title bar’) when using the following in _form.html.erb:
<%= t(‘errors.template.header’, :count=>@order.errors.size,
:model=>t(‘activerecord.models.order’)) %>:

so maybe update the figure, or modify the template to match it?

2010-07-25
229SUGGEST

also, the payment methods aren’t localized, not sure how much work it would be to do this. So it might’ve been skipped on purpose.

2010-07-25Added as a playtime exercise
180ERROR

The book shows source code for the mailer which is generated. This is not however correct to the code generated by rails. The command issues on this page creates the files, but their content is just stub content. This source on the page is populated already with meaningful code in relation to orders etc.. The generated code is simply generic.

2010-06-26
185OK

When we run the functional tests at this point, the tests will fail for sending the order shipped email.

At this point in time we have not actually defined the text and html content for shipping the emails. This isn’t actually done at all in the chapter, and the tests will not pass.

2010-06-28Rails provides initial text templates, enabling the tests to pass.
160OK

the code example for _form.html.erb is:

it should be

2010-06-28Correct as is, needs to match: \n \nhttp://media.pragprog.com/titles/rails4/code/depot_p/public/stylesheets/scaffold.css
194SUGGEST

In the password= definition, is it neccessary to assign self.salt = …. when the function generate_salt assigns the value to self.salt? Surely this means the call should just be:

if password.present?
generate_salt
self.hashed_password = …..
end

2010-06-27
19TYPO

Epub specific bug: “Ruby and Rails at the same time. the Section …” Whatever magic is making the epub version different from the PDF with respect to chapter / section linking is broken :) it’s all throughout the book, so I won’t bother reporting it any further — it’s probably all the same macro.

2011-03-04
43TYPO

(At least I think it’s on page 43 of the PDF; my sony reader reports page 50 in the epub version.)

epub bug, % is on a different line than > in one of the erb examples. Is there any way to tell epub readers to not split <% and <%= and %> (and others..) in the code examples?

2011-03-02I'm afraid not....
42OK

“method names are used , Rails applications”

s/ , /, /

2010-06-19
50TYPO

Another epub-specific bug: “|order|” has been broken across lines in the code listings on my sony reader.

2011-03-02
63TYPO

“help you with your Rails coding”

Missing period.

2010-06-19
72SUGGEST

“be using a database—sometimes a flat file beats a database table hands down.”

I’d be more willing to believe this if any of the previous three versions of this book had ever used a flat file for data storage. :) Okay, there’s plenty of yaml files around, but those aren’t very flat. And I’ve never seen one tied into a model in the application. Maybe it’s time to let this sentence go. :)

2010-06-19dropped second half of the sentence.
77TYPO

The migration filename doesn’t match the cut-n-paste rails generate scaffold output. (I know you cover this in a bit, but perhaps “The one we’re interested in first is the migration*_create_products.rb” would make more sense than hard-coding the wrong datetime and version string. :)

2010-06-19
78TYPO

The parenthetical statement beginning: “(If you get an error saying Address already in use” doesn’t have a close parenthesis.

2010-06-19
89SUGGEST

All the validation examples are off the edge of the page on my sony reader on the epub format.

2011-03-02Sorry—not much we can do about that...
105SUGGEST

I suggest describing the ‘raw’ method in more detail. Those of us coming from older versions of Rails are used to h() html-escaping everything by hand. And it got tedious. If the presence of ‘raw’ means what I think it means, it is a glorious day for RoR programmers, and a giant step in the right direction.

Rails goes a very long way to remove giant classes of security bugs, and it makes sense to tout the features at every turn. (I dream of a php-free day. register_globals was just the tip of the iceberg, and Magic Quotes shows how little the php team cares about the integrity of your data..)

I’d also find it useful to have a sidebar or side-helper thingy mention that for almost-trusted inputs that you could instead use markdown or any related flavor of html-generating thing that also prevents raw html from coming through. Some pointer to say “there’s middle ground between all or nothing.”

2010-07-24Switched to that fabled middle ground: sanitize; and provided a pointer to the point in section 3 were this is discussed further.
105TYPO

“it will the layout used”

s/will the/will be the/

2010-06-19
109TYPO

“all this new function.”

s/function/functionality/

2010-06-19
114SUGGEST

“We’ve got the session stuff sorted out”

It sure didn’t feel sorted out to me! :) The session object is just used without much in the way of fanfare. I think it’d be fair to put in a few sentences about where the data in the session goes between requests, its lifetime, how well you can trust the data in the session, just what kind of data is appropriate to put into the session, what needs to be revalidated after being loaded from the session…

It doesn’t feel at all ‘sorted out’. :)

2010-06-25Added a forward pointer to where it will be covered in depth.
115TYPO

“an Cart”

Either “a Cart” or “Cart” would scan better.

2010-06-19
116TYPO

“add an :product_id”

Either “add a :product_id” or “add the :product_id” would scan better. (I suggest ‘the’, because symbols are singletons.)

2010-06-19
119TYPO

“lets write a a trivial”

s/a a/a/

2010-06-19
120TYPO

The bullet points are inconsistently capitalized and punctuated.

2010-06-21
122TYPO

“adding a one or more columns”

s/a //

2010-06-19
122TYPO

“data type each this column from last argument.”

I’m not sure how to fix this. :)

2010-06-21
124TYPO

“for each the line items”

s/each the/each of the/

2010-06-19
125TYPO

“greater than one, Adds new line items”

s/Adds/adds/

2010-06-19
129TYPO

The text “See figure … on page … for a much more user friendly result.” is referring to the wrong figure. (In this version of the PDF, it is referring to figure 10.5 on page 134, but the figure is 10.4 on page 130. In the epub format, the name of the wrong figure is given.)

2010-06-25
130ERROR

Very unsafe destroy() method in file depot_h/app/controllers/carts_controller.rb.

This destroy method allows someone to destroy every single shopping cart on the system. The cart should be scoped by user. (If this is for simplicity here, PLEASE put a comment in the code along the lines of “never do this, see section …”.)

2010-11-10
131TYPO

“but it won’t valid according to spec.”

In the David Says… sidebar.

s/won’t valid/won’t be valid/

2010-06-21
135TYPO

AJAX and Ajax are both used on this page. AJAX is also used in a section header on 150.

2010-06-25
142TYPO

“Rails will look for an create template to render.”

s/for an create/for a create/

2010-06-21
151OK

Something seems a bit silly about the application.html.erb snippet:

<% if cart %> <%= hidden_div_if(cart.line_items.empty?, :id => “cart” ) do %>
<%= render @cart %>
<% end %>
<% end %>

The whole point of hidden_div_if was to code around an empty cart. Changing the condition like this should work:

hidden_div_if(cart.nil? || cart.line_items.empty?)

2010-06-28All hidden_div_if does is set the display:none CSS property. \n \nWhat we really want to do is prevent the call to render @cart if there is no cart.
158ERROR

The figure “Names in form_for map to objects and attributes” has a form like this:

<% form_for :order, :url => { :action => :save_order } do |form| %>

but the code snippet has a form like this:

<% form_for @order do |f| %>

2010-06-25
164SUGGEST

I was very lost for most of this section, and I didn’t realize why until “All that is left is to define the relationships themselves”. The relationships are the whole point…

I had trouble following along the view code and the control code because I had no idea what the data looked like. I always find the layout of data easier to understand than code. (This might be the closest I ever get to being Fred Brooks. :)

Please consider moving the models towards the head of the iteration.

2010-07-24
164TYPO

“And we modify the test fixture to so that”

s/to/too/

2010-06-19
170TYPO

“we need to define an route”

s/an route/a route/

2010-06-19
173TYPO

“(feel free”

Unmatched parenthesis.

2010-06-26
175TYPO

“linked it a new order model.”

s/linked it a/linked it to a/

2010-06-26
178TYPO

“created an Notifier class”

s/an Notifier/a Notifier/

2010-06-26
179ERROR

The text mentions “confirm.erb”, but the mail template is in order_received.text.erb.

2010-06-26
182ERROR

$RAILS is used undefined in the Joe Asks sidebar.

2010-06-26
183TYPO

Inconsistent capitalization between “Unit testing of models” vs “functional testing of controllers”.

2010-06-27
188SUGGEST

SHA-2 should be used in place of SHA-1 for new applications. SHA-1 should only be used for interoperability with existing applications that have not yet been upgraded. Salted passwords are probably still fine with SHA-1, but this is an opportunity to learn good habits for the next decade. :)

2010-07-24
188OK

“used elsewhere in the all-to-common case where”

s/to/too/

2010-06-28Correct as is.
193TYPO

“let’s avoid the redirect to showing the user after either a create operation.”

Suggest delete ‘either’. Could also read “after both create and update operations.” or “after either create or update operations.”

2010-06-27
193OK

The @user.name is passed directly to the flash :notice without any HTML escaping. Is the flash rendered with or without HTML escaping? My guess is that the flash is rendered raw, in which case the user.name is a vector for cross-site scripting flaws.

2010-06-27The notice is inserted into the view using <%= notice %>, which will HTML escape the content unless the view is modified to specify raw.
201TYPO

Missing period after “We will describe all that you can do .. routing … ”

2010-06-26
202TYPO

“In our case, we’ll use a before4filter to intercept”

s/before4filter/before_filter/

2010-06-26
202TYPO

“exposed to end user as an action.”

s/user/users/

2010-06-26
208TYPO

“Plugins that provide a ready made solution”

s/ready made/ready-made/

I thought “Plugins that…” was inelegant when I first read it, but I have no suggestions how to improve it. :)

2010-06-26
210TYPO

“and we are going to have to changes the views to make use of these translations”

Suggest: “have to change the views to use these translations”

2010-06-27
212OK

In the internationalization section, the routes are scoped with :locale, which provides foo/en, foo/es, foo/de, etc versions, which is nice, but there’s no use of the standard HTTP header Accept-Language. Pity.

If Accept-Language were used to set the locale initially, the clear majority of users would never need to set their language. (I try to keep my German sharp by reading the German wikipedia — so I’m very glad to have easy URL-based mechanisms to select between the English and German versions, so I wouldn’t want to remove the paths! :)

2010-11-12
212TYPO

“but only if there is a locale value is in the params”

s/value is in the/in the/

2010-06-27
216TYPO

“the some actual translated text”

Suggest: “the translated text”

2010-06-27
217TYPO

“Rails will also treat as HTML key names that with the name html itself.”

Please revisit :)

2010-06-27
222TYPO

“will will want”

s/will/we/

2010-06-27
222SUGGEST

Order::PAYMENT_TYPES is left untranslated in the translated application — so Credit Card, Check, and so forth are kept. That’ll be funny for most of the world, as plenty of English speakers use Cheque, and perhaps confusing for chinese or korean or languages not derived from europe :)

2010-07-25Made a playtime exercise
228SUGGEST

Please explain why the input tags in the locale form need to be hidden. The whole javascript_tag portion of the snippet is really confusing, and makes me wonder just what else will require some baffling javascript.

2010-07-25
236SUGGEST

You say you’d like to cut down the active record chapter by a factor of 3 or 4. Strictly from a page count, I can understand that that’s a ton of paper :) but the in-depth view of active record in the previous books was always my favorite part. And, now that the ORM layer can be swapped out, I would like some mention of why (and maybe how — depends on the why. :)

2010-06-27Next beta will contain the streamlined chapter. Mostly it was done by eliminating the reference material descriptions of each parameter, and duplication of content already covered in Depot. Feedback welcome. \n \nAlternatives will be described in a subsequent chapter.
241TYPO

“is not in the core of Rails does no mean that it isn’t”

s/does no mean/does not mean/

2010-06-27
241SUGGEST

I didn’t see any reference to action caching, page caching, fragment caching, or using memcached to add object / list / tree caching.

I think Rails is slow enough that caching is going to be required for anything remotely popular..

2010-07-25Caching will be covered in chapter 20.
241OK

I’ve seen a lot of references to datamapper and jquery while browsing Rails blogs. I think perhaps they could justify another page or two, to help understand why they are so popular. Thanks!

2010-07-25chapter 25 will cover these
98TYPO

First sentence of third paragraph down.
Reads: Let’ add some more data…
Should be: Let’s add some more data…

2010-06-19
34ERROR

The command to create a new rails app is listed as “rails demo”, but this will not work in Rails 3. You must use “rails new demo”

2010-06-19
216OK

In “..aliased as I18n.t, but there also…” the t looks like it’s the wrong font?

2010-11-12
26OK

You’re suggesting to use sudo gem update —system, which may make a mess in the system (i.e. interfer with distro package management) and does not work reliable. I suggest to spend an extra page on rvm and using that instead.

2010-11-10My primary system is Ubuntu, and I've been successfully doing this for years.
211ERROR

When someone tries to delete an user a flash notice is set but the code to display the notice in the view is missing. At this point of the book anyone should know to display a flash but still…

2010-11-12
208ERROR

It has to be

page.select(“p#notice”).each

as the flash notice does appear in a p-tag, not directly in the div.

2010-06-26
209ERROR

I copied those files from your server but when calling the URL as mentioned in the text the app throws the following error:

ActionView::Template::Error (undefined method `orders’ for #):
1: atom_feed do |feed|
2: feed.title “Who bought #{@product.title}”
3:
4: latest_order = product.orders.sort_by(&:updated_at).last 5: feed.updated( latest_order && latest_order.updated_at ) 6: 7: for order in product.orders

Did I miss something in the steps before or is it a real error?

2010-06-27
111TYPO

Missing apostrophe on “That’s” in the sentence that begins with “Thats a reasonable beginning”

2010-06-19
234TYPO

“One such tools, namely”

s/tools, namely/tool,/ (okay, the ‘namely’ part is more style than typo, but it seems out of place. :)

2010-06-27
234OK

The first time I’ve encountered the name “Phusion Passenger” is in the sidebar about MS Windows. I think something as fundamental as the server-based ruby interpreter should get much stronger billing than being stuck in a sidebar about one specific operating system. Further, until reading further, I had no idea what role Phusion Passenger played in the deployment, so I wasn’t sure I was even going to bother with it.

It’d be nice to mention other possible deployments too. Back in the day, lighttpd with FastCGI was the preferred deployment method. Now, it seems nginx with … what? is the preferred deployment method. Apache is tried and true, but might have too many levers and knobs for its own good.

I guess this far out-paces an iteration in the depot application; but I’d like to know the tradeoffs between the most popular four or five web servers, most popular three or four CGI-replacements, etc.

I know all this is subject to rapid change — lighttpd was the hot new kid on the block just a few years ago, and now no-one remembers its name, because nginx is the neat new thing — but some of us old guys would like to know why the previous best deployments are no longer even mentioned..

2010-06-27The purpose of the sidebar is to state to Windows users that this chapter is not for them, and it needs to say way that is. That does mean that Phusion Passenger is mentioned first in a sidebar, which is unfortunate but necessary. \n \nThe purpose of Part II is to describe the "golden path", or the Rails Core team recommended approach. Alternatives are covered in Part III.
238OK

When suggesting to people that they should edit their /etc/hosts file to add in their deployment IP, I think you really should put some big bright warning that this is just for demonstration, and that OF COURSE you should use DNS to do DNS’s job. Otherwise, people will forget they fiddled with their /etc/hosts and something will break in the future. (It just will.)

2010-11-14
238SUGGEST

“We can restart our application without restarting Apache at any time by creating a file named tmp/restart.txt:”

Relative to what directory? /? /home/sarnold/? /var/www/?

2010-07-25
239OK

The MySQL database creation code doesn’t specify InnoDB.

The default storage engine for MySQL doesn’t understand ACID and certainly doesn’t understand transactions. It also doesn’t understand Foreign Key constraints, which means Rails is 100% in-charge of enforcing the sanity of the database. (I wouldn’t even run two Rails clients connected to the default MyISAM storage engine for MySQL. It might work just fine most of the time, but there’s no need to run the risk against the time that it blows up into a thousand disconnected pieces.)

PLEASE create the database using InnoDB.

(Or, consider switching to PostgreSQL, where no such details are necessary. I know you’ve already written a ton of MySQL content, but MySQL’s continued default use of non-ACID, non-transaction, non-FK storage engine baffles me. For any application where that is appropriate, SQLite3 is already much better suited.)

2010-11-14
240SUGGEST

In the MySQL troubleshooting section, there is an attempt to connect to the MySQL server using root, but there are no attempts to connect to the server using the user name required for the application, nor specified from which machines. Since the database is going to be doing access controls based on usernames, selecting the correct one is important. Also, most admins firewall their database servers so they are only available from certain machines, so the source machine is as important as the destination machine. (Most admins also configure the database server to allow connections for users only from the machines where those users should be deployed. Belt and suspenders when it comes to your customers’ data.)

2010-07-25
242OK

Why create a new dsa key? Chances are good the user already has an rsa key, and creating a second key is potentially very confusing.

Also, what distributions have changed the default ~/.ssh/authorized_keys file to authorized_keys2? (Smells like a funny / strange / old version of an ssh server to me.)

2010-11-13
256TYPO

“which will create this layouthis layout for you.”

s/lay.*you/layout for you/

2010-06-27
264TYPO

“When starting WEBrick using with the rails server command”

Delete either ‘using’ or ‘with’. Probably delete ‘using’, because ‘use the -e option’ immediately follows, and no one needs two ‘use’ in one sentence. :)

2010-06-27
218TYPO

“The :test setting is great for unit and functional testing, which we will make use of in the section Function Testing E-Mail. .”

One full-stop too much. I’m reading the ePub version, the chapter which I’m referring to is Iteration H1, the first page.

2010-06-27
220OK

It seems like the filenames on the pages 220 and 222 are identical.

2010-06-27Different portions of the same file
105TYPO

Use “default_scope :order => ‘title’”

2010-06-19
121SUGGEST

Use assigns(:line_item) instead of LineItem.last to stay more consistent

test “should create line_item” do

assert_redirected_to cart_path(assigns(:line_item).cart)
end

2010-06-21
108SUGGEST

Expand the width of the sidebar

#main {

margin-left: 20em;
}

#side {

width: 19em;
}

Otherwise when adding the ajax effect later, an ugly overlap into the main area appears when new items are added and flashed

2010-11-12
149OK

Looks bad to have the highlight effect go off when doing the blind-down effect. Here is a fix:

page[:cart].visual_effect :blind_down if cart.total_items == 1 page[:current_item].visual_effect :highlight, :startcolor => "#88ff88", :endcolor => "#114411" if cart.total_items > 1

2010-07-24
173SUGGEST

Advise reader to restart rails server in order to refresh the routing information so that curl can retrieve the atom feed using the new route :)

2010-07-24This should *not* be necessary (it was in Rails 2.x, but not in Rails 3.0).
183OK

Missing order_shipped view templates in order to run notifier test. Also missing how to run mail test:
$ rake test:functionals

where mail method is configured to :test

  1. order_shipped.text.erb
    Dear <%= order.name %> Thank you for your recent order from The Pragmatic Store. We have shipped the following items on <%= Date.today %> : <%= render order.line_items -%>

# order_shipped.html.erb

Dear <%= order.name %>,</strong></p> <p>Thank you for your recent order from <em>The Pragmatic Store.</em></p> <p>We have shipped the following items on <em><%= Date.today %></em> :</p> <table><%= render order.line_items -%>

In order to make DRY notifier templates, partials should be used!

2010-06-27These files are produced by rails generate mailer Notifier order_received order_shipped 183SUGGEST

What if I want to use a specific (other) line_items partial in the notifier emails than the one used on the html page.
<%= render @order.line_items -%>

In other words, describe how to explicitly tell rails which partial to use.

Also, when I in the folder views/line_items have the two partials _line_item.text.erb and line_item.html.erb I still get this error!? Should I use the “plain” part in some way?
This part of the book is really confusing…

ActionView::Template::Error: Missing partial line_items/line_item with {:handlers=>[:erb, :rjs, :builder, :rhtml, :rxml], :formats=>[:text], :locale=>[:en]} in view paths “/Users/kristian/depot/app/views”

Hmm, do I need to add a format.text statement or perhaps a responds_to :text at the top of the controller?

2010-07-24This will be explained in chapter 21. 197OK

mention alternative to add a default_scope to user model similar to product instead of having the order(‘name’) in the controller. Mention use of scopes in general.

2010-06-27Default scopes were introduced on page 104. Scopes will be covered in the chapter on Active Record. 203ERROR

Changing the routes to use login instead of sessions/new is very nice, but it requires an update to the sessions/new.html.erb view to align it.
Also, this error is not caught by the functional test.

The HTML source code for sessins/new.html.erb (login form)

— form method=“post” action=“/sessions/new”

I was wondering why you use the will-paginate plugin but not a similar plugin, such as devise or authlogic for security?

2010-07-24Sessions new uses form_tag: \n \nhttp://media.pragprog.com/titles/rails4/code/depot_p/app/views/sessions/new.html.erb \n \nThe intent of Part II is not to demonstrate the ecosystem around Rails itself, but to demonstrate Rails. A single plugin was selected, in order to demonstrate how to make use of a plugin. 238OK

There is no mention that you have to run
$ rake db:migrate RAILS_ENV=production

In order to setup the database in production mode for the site to run when deployed.

2010-07-25rake db:setup does this (page 240) 230OK

Showing /Users/kristian/depot/app/views/stor/index.html.erb where line #5 raised:

syntax error on line 1, col 19: ` number: currency:’

No matter what I do, I always get errors on the yaml locale file. Please post a yaml file that works as is. How do I handle whitespaces in yaml to make sure it works!?

2010-07-25http://media.pragprog.com/titles/rails4/code/depot_s/config/locales/en.yml \nhttp://media.pragprog.com/titles/rails4/code/depot_s/config/locales/es.yml 178TYPO

Last sentence of first paragraph:

Reads: “…we will create tests not only the for the mail support that we just added…”
Should be: “…we will create tests not only for the mail support that we just added…”

2010-06-26 180TYPO

Third paragraph, second sentence:
Reads: “(We also created a test files…”
Should read: “(We also created a test file…”

2010-06-26 125OK

Before the new column ‘quantity’ could be successfully used in an expression, I needed to use dbconsole to actually initialize the value to something other than SQL null. RoR was throwing a nil object error when ‘current_item.quantity’ was referenced on line 15 of cart.rb. I’m using sqlite3.

Could be cockpit error but this fixed the problem.

2010-07-24Can't reproduce. 76ERROR

it says:
work > rails depot

it should be:
work > rails new depot

2010-06-19 176TYPO

grammatical errors …

‘and the links will only show up if there are more than than one page full’

2010-06-26 177TYPO

‘We created a form to capture details for the order and linked it a new order model.’

change to .. ‘linked it to a new order model’

2010-06-26 177TYPO

‘Can you find a way of disabling the button in this circumstance?’

to

‘Can you find a way to disable the button in this circumstance?’

2010-06-26 163ERROR

The line_item yml as shown is invalid. It references order: instead of cart:. Also, it should be more clear that the order yml should be modified to correct the payment type for the orders since you introduced validation on the order type.
You only show the line_item fixture in the code listing.

2010-06-26 166TYPO

‘And we modify the first order to’
.. should be ‘too’

2010-06-19 167ERROR

The line_item fixtures as defined make sense at this point, but to reiterate my previous note on line_item fixtures, they did not make sense on page 163 because orders had not been associated to line_items at that point. That section was confusing.

2010-06-26 172TYPO

‘To make this work, we need to define an route’

change to ’… define a route".

2010-06-19 217TYPO

First paragraph, Second sentence.
Reads: “We can chose any name we like…”
Should read: “We can choose any name we like…”

2010-06-27 163ERROR

After adding validations rules, you say that the fixtures must be updated, but the example code shows you updating the fixtures from line_items.yml, when really you should be updating the fixtures in orders_yml.

The only thing that needs to be updated for the functional tests to pass is the pay_type parameter, as we added the validation for inclusion of PAYMENT_TYPES only. Once that change is made, the tests will no longer fail.

I noticed this because you describe updating the same fixtures with the same changes twice, on page 163 and page 167.

Hope this helps!

2010-06-26 179ERROR

in create.js.rjs:
page.select(“div#notice”).each do { |div| div.hide }

should be using ‘p’ instead of ‘div’

2010-06-26 121TYPO

“The remainder of this method takes care of xml requests, which we will cover in on page 273, …”

Correct the “…cover in on…” in this sentence. It should probably be something like “…cover on…”, or “…cover in more detail on…”:

2010-06-25 131TYPO

Underneath the excerpt from the development.log file, there is the line:
“See Figure 10.5, on page 136 for a much more user friendly result.”

I think this reference should be to Figure 10.4 on page 132.

2010-06-25 78TYPO

This may be a minor typo. Page 78 reads as such: The one we’re interested in first is the
migration20100301000001_create_products.rb.

This should read: The one we’re interested in first is the
db/migrate/20100404030855_create_products.rb

Or read as such: The one we’re interested in first is the
migration20100404030855_create_products.rb

The file numbers don’t match on page 77 and 78. This correction matches them.

2010-06-25 80TYPO

Page referred to incorrect: These forms are simply HTML templates, just like the ones you created in
Chapter 2, Instant Gratification, on page 34.

It was page 37 I believe.

2010-07-24 82TYPO

Minor typo: Reads: At this point, you’ve done a lot a total of four commands. Should read: At this point, you’ve done a lot for a total of four commands.

2010-06-25 88SUGGEST

please specify where .gitignore is stored. From the text below and what was written above, it is not clear where to store the file .gitignore. Is is it in the home directory?(I would assume as that is where we put the one above(.gitconfig)

Note that Rails applications are already set up to tell Git to ignore a few
files. This is accomplished by providing a file named .gitignore:
Download depot_b/.gitignore
.bundle
db/*.sqlite3
log/*.log
tmp//*

2010-06-25 19OK

No explanation of what green pointers indicate. In the How to read this book section the below code exists with green pointers pointing to some lines of code. No where I can find does it explain what these green pointers indicate(I have read to page 88 so far).

class SayController < ApplicationController
def hello
end
def goodbye
end
end

2010-06-28On Page 20 it says: \n \nAnd in some cases involving the modification of an existing file where the lines to be changed may not be immediately obvious, you will also see some helpful little triangles on the left of the lines that you will need to change. Two such lines are indicated in the previous code. \n 117TYPO

“And because an Cart” perhaps should read “a Cart”.

2010-07-24 26TYPO

I had to “sudo port install rb-rubygems” (and then reinstall the required gems) in order to get the “for cmd …” and “require ‘rubygems’ … ” scripts to work as described here. Rubygems and Rake were both still in their default locations, and “require ‘rubygems’ ” failed.

2010-07-23 275ERROR

“ruby treats everything that is not false or nil as false”

shouldn’t that be “false or nil as true”?

2010-06-30 279TYPO

One of the ways Rails differs differs from - > One of the ways Rails differs from

2010-06-30 181TYPO

E-mail will not be delivered but instead

E-mail will not be delivered, but instead

2010-07-24 181TYPO

If you do so, though, you’ll need also to specify some additional

If you do so, you will need to specify some additional

2010-07-24 181TYPO

Any particular reason you double quote all of the smtp setting values except for the authentication value?

2010-07-24 183TYPO

We can customize the template in order_received.erb

We can customize the template in order_received.text.erb

2010-07-24 184TYPO

basics in place that you can place an order and have a plain email to yourself

basics in place that you can place an order and have a plain email sent to yourself

2010-07-24 184TYPO

Inconsistent on usage of email vs e-mail

2010-07-24 184TYPO

Now lets spice the email up

Now let’s spice the e-mail up

2010-07-24 186TYPO

Unfortunately, you also need to find a way of getting appropriate e- mails from your server environment and injecting them into the application;

Unfortunately, you need to find a way to retrieve appropriate e-mails from your server environment and inject them into the application;

2010-07-24 187TYPO

The test method get the mail class to create

The test method gets the mail class to create
..or..
The test method instructs the mail class to create

2010-07-24 187TYPO

we have verified that the message that we intend to create

we have verified that the message we intended to create

2010-07-24 187TYPO

Before cover-ing integration tests, a brief recap of what we have covered so far.

Before explaining integration tests, let’s have a brief recap of testing strategies we have covered so far.

2010-07-24 187TYPO

Model classes contains business logic. When we add a product to

Model classes contains business logic. For example, when we add a product to

2010-07-24 187SUGGEST

You have a heading titled ‘Unit testing of models’, but do not mention unit testing in the context of business logic. Actually, you do not mention testing at all in that section.

2010-07-24 25OK

I think that it’s really worth giving a brief look to RVM, and perhaps the use of .rvmrc to switch gemsets when you enter your project directory.

2010-11-10What I am about to say is not likely to be popular :-) \n \nI'm a big fan of RVM, and use it heavily myself. But it seems to be targeted at people who aren't the target audience of this book: people who may not even know Ruby and certainly aren't ready to manage gemsets for themselves. 289TYPO

In the section on “lock” the text “If don’t specify…” should be something like “If we don’t specify…”.

2010-07-25 63SUGGEST

The description of public, protected, private is what you would expect for any object oriented language. Perhaps it should have a warning that anyone with a web browser can call public controller methods, and refer to the use of private in section 9.1 page 119.

2010-07-23With Rails 3.0, the wildcard route is no longer present by default, and strongly discouraged. This means that public methods are not exposed unless an explicit route is created. \n \nI did add a link back to the definition of private from where it is used later. 167SUGGEST

The code snippet at the bottom of the page where the has_many association is added to the Order model might suggest that the entire order.rb file contains only these three lines of code, ignoring the additions to this file made earlier. I suggest adding a yellow arrow to the left of the has_many line, and either replacing the “end” on the next line with “#…”, or including the entire code for the model at this point.

2010-07-24 136SUGGEST

You define this possibility:

Playtime
Here’s some stuff to try on your own:
• Create a migration that copies the product price into the line item, and
modify the controller to capture the price at the time of the order.

And on page 168:

sqlite> select * from line_items;
id = 1
product_id = 3
order_id = 1
quantity = 1
total_price = 28.5# <<<<<<<<<<<<<<<<<<<<<<<<<
created_at = 2010-06-09 13:40:40
updated_at = 2010-06-09 13:40:40

You assume that the reader went through will that “Playtime” suggestion, this might throw off people that did not, people that simply went through with the required steps as described in the main body of the book… this may make some feel like they’ve missed a step.

2010-07-24 76TYPO

(Bottom of page, in command type)

rails new depot

should be

rails depot

2010-07-23 77OK

Bottom of page: I think you want “./script/generate” not “rails generate”

2010-07-24./script/generate was for Rails 2.3 and prior. With Rails 3.0, this was replaced by rails generate. 80OK

Don’t you need to explain how to render a partial here? (_form.html.erb)

2010-08-12In due time. At this point, we are simply showing that you can make a change and see the results instantly. Soon enough, we will show how the parts fit together. 84TYPO

In the section for the application layout, isn’t the file “product.html.erb”, not “application.html.erb”?

2010-07-23 84OK

Not sure that “csrf_meta_tag” is defined anywhere in the app yet.

2010-07-24That's inserted by Rails. 34SUGGEST

Instead of “rails demo,” should be instructed to write “rails new demo”

2010-07-23 93OK

In the products_controller_test.rb, I could only get it to work with “def setup”, not with “setup do” — the former can see the helper “products”, the latter doesn’t seem able to.

2010-07-24I can't reproduce. 106OK

Code block in middle of page, I think you want “:notice” not “notice”

2010-07-24 177OK

I had to restart the server after configuring pagination. Before doing so I was getting the will_paginate generates undefined method paginate error.

2010-07-24Should not be necessary 86ERROR

Text says:

We loaded some test data into the database, we rewrote the index.html.erb file that displays the listing of products, we added a depot.css stylesheet, and we linked that stylesheet into our page by editing the layout file products.html.erb.

It should say:
…we linked that stylesheet into our page by editin the layout file application.html.erb

2010-07-23 141ERROR

When updating the StoreController, the method ‘current_cart’ is referenced, but this is the first time that the method is referenced. I think the method that should be referenced (and I have tried, and verified works) is the ‘find_or_create_cart’ method previously mentiond/described/used

2010-07-24I've switched everything to current_cart. 148OK

The previously used <% =render(…)%> is no longer used after this point

2010-07-24I don't understand this comment. 231ERROR

order.add_line_items_from_cart(find_or_create_cart) should be order.add_line_items_from_cart(current_cart)

2010-07-25 25SUGGEST

On MacOS X 10.6, to run sudo gem install sqlite3-ruby, you need to have installed XCode v.3.2.x, otherwise you get some ruby header missing error. You may want to mention this to users so they don’t get tripped up on this step.

2010-07-23 57SUGGEST

Probably should use something besides ‘Pa’ for the expression interpolation example, because ‘Pa’ is already capitalized.

2010-07-23 25ERROR

You suggest running
% sudo gem update rails —pre

if you’ve never installed rails and are running on a clean 1.9.2 install this won’t work. You need to sudo gem install rails —pre

You suggest running
% sudo gem update rake

With ruby 1.9.2 rake comes bundled and is not a gem. There will be nothing to update. If you make the mistake of `sudo gem install rake` (in case you went with the flow of installing rails above) then you’ll overwrite your ${RUBY_BUILD_PREFIX}/bin/rake wrapper script with a broken gem installation.

2010-07-23 289TYPO

paragraph begins “If don’t specificy…” assuming it should ready “If we/you/etc don’t specify…”

2010-07-25 98SUGGEST

This one might just be me, but when the class ‘ProductTest’ is mentioned at the bottom of the page here, it took me a few minutes to understand that we were talking about the same file we had been writing the tests in. I know I’m dumb, but it spoilt the flow for me as until this point I had known exactly where I was and what was going on (which shows how well the book was guiding me!). Maybe specify the file name/path ‘test/unit/product_test.rb’ again in brackets? - BTW. thanks for this book! Finally beginning to understand rails!

2010-07-23 164OK

The code for the fixtures in line_items.yml reads:

one:
product: ruby
cart: one
two:
product: ruby
cart: one

When I did this, it caused the should_destroy_product test to fail. I still can’t figure out why it failed, but changing the code to the following fixed and all tests passed:

one:
product_id: Products(:ruby).id
cart_id: Carts(:one).id
two:
product_id: Products(:one).id
cart_id: Carts(:one).id

Seems the fixture needs the ids defined as opposed to the objects for some reason. Also, seemed more correct to use a different product for the second line item since we changed model to use one line item per product in each cart.

2010-07-24I can't reproduce 167ERROR

Same problem here with test fixture as on Page 164. The should_destroy_product test fails until I change the line_items fixture to specify product/order/cart ids instead of the objects.

2010-07-24Unfortunately, I still can't reproduce 288TYPO

On the following line:
list = Talks.select(“title, speaker, recorded_on” )

Wouldn’t the name of the class typically be “Talk” not “Talks”, i.e. the singular of the table name.

2010-07-25 289ERROR

Doesn’t the following fail:
‘Order.minimum(:amount).where(“amount > 20” )’

as minimum returns a Fixnum thus “where” isn’t a method on Fixnum. Something like the following works:

Product.where(“price > 20”).minimum(:price)

at least in my testbed (i.e. ruby 1.9.2-rc1 and rails 3.0.0beta4)

2010-07-25 288TYPO

minor bug, there’s an extra ‘.’ before “group” on the following lines:
summary = LineItem.select(select => “sku, sum(amount) as amount” ).
.group(“sku” )

2010-07-25 290ERROR

there is a minor bug on these lines:

result = Order.maximum(:amount).
.group(:state).
.limit(3).
.order(“max(amount) desc” )

i.e. the extra ‘.’ at the end (or beginning) of each one. Also, I believe the maximum() call has to go at the end as it returns an actual number and thus can’t be chained this way.

2010-07-25 289ERROR

I believe this line:
result = Order.maximum(:amount).group(:state)

needs to be reordered with the maximum at the end like so:
result = Order.group(:state).maximum(:amount)

I didn’t have the data to test this exactly, but with some orders in depot the following works:

Order.group(:email).maximum(:created_at)

whereas putting the maximum first errors with ‘maximum’ not being a method on UTC:Time

2010-07-25 290ERROR

orders = Orders.last_n_days(7)

‘Orders’ should be the class ‘Order’

2010-07-25 48TYPO

“we will be making heavy use of Rail’s ability” => saxon genitive for “Rails” should be “Rails’s ability” or “Rails’ ability”, I guess

2010-07-23 25TYPO

The very first line says: “[…]. This book uses only tso Unix commands.”

Here is a typo. You probably thought about two Unix commands :)

2010-07-23 48OK

In figures 3.1 and 3.2, there is a gray dashed arrow which goes from Model to View, different from the other arrows in the figures. I think it’s not clear the meaning of that arrow: can Model communicate directly with the View in some special way? Why is there not an arrow that goes from the View to the Model?

Sorry for my english, I hope I was clear!

2010-11-10 167SUGGEST

Very confusing. The section where we define the relationship between LineItem and Order seems as though it should have occured at the start of the chapter (12)(page 156). Especially since the previous paragraph mentions “the has_many and
belongs_to declarations we added to the Order and LineItem models” when we haven’t added them yet. Also, the start of chapter outline lists the topics “linking tables with foreign keys” and “using belongs_to, has_many, and :through,” as the first two subjects to be covered.

2010-07-24 175OK

book states “We need to specify that we want a version
that is greater than or equal to 3.0.pre as previous versions don’t work with
Rails 3.0.”

When running ‘bundle install’ I get the error:

“Could not find gem ‘will-paginate (>= 3.0.pre, runtime)’ in any of the gem sources.”

2010-07-24Just retested and got: \n \nInstalling will_paginate (3.0.pre) from rubygems repository at http://rubygems.org/ 175OK

Ignore previous Erratum (#44094) - dumb typo on my part.

Though, I did need to upgrade Sqlite3 on OS X (leopard) and run ‘sudo bundle install’.

2010-07-24 130TYPO

Current text is:

Armed with all this background about flash data, we can now change our create method to intercept bad product ids and report on the problem:

The problem is that the code below and the changes made are to the show method not the create method.

2010-07-24 135OK

Current text is:

/* Styles for the cart in the main page */
#store .cart_title { font: 120% bold;
}
#store .item_price, #store .total_line { text-align: right;
}
#store .total_line .total_cell { font-weight: bold; border-top: 1px solid #595;
}

I’m no CSS guru but it seems redundant to include #store twice on the row with .item_price and .total_line, and the block after this one seems to do this without repeating itself.

2010-07-24The comma means that there are two declarations that share the same block. In the snippet above, there are a total of four CSS rules, all of which start from #store. 102ERROR

Since the end of Chapter 6, there shouldn’t have been any modification done to app/views/layouts/products.html.erb, so the output from

$ git status

should not include this line:

  1. modified: app/views/layouts/products.html.erb
2010-07-23 102ERROR

In the Playtime section, adding:

validates_length_of :title, :minimum => 10

to the product model did not result in any unit test errors even though it says:

Note: this will cause tests to fail, so you will need to
update the fixture data for products.

The fixture data for the product title is: “Programming Ruby 1.9”

2010-07-23 145SUGGEST

The width for the sidebar is too narrow. When adding the item Programming Ruby 1.9 it overflows into main. Changing the width for the sidebar to 14em and changing margin-left in main to 15em fixes this but it really isn’t a very good solution. The problem in this case is the word “Programming”, which is too large to fit, this fix just bypasses the width problem for this specific case and if you create an item with a longer word like “Antidisestablishmentarianism”(longest word found on wikipedia) you have the same problem again. There must be a better way around this, maybe the cart should be moved to the bottom instead in an floating div?

2010-11-12 150TYPO

The listing for helper files is incomplete it contains helper files for application, carts, line_items, products and store. I don’t know if this was intentional?

2010-07-24 161OK

Maybe reminder to delete layout/order.html.erb so that the .css gets picked up?

2010-07-24That should not be necessary with Rails 3.0. 164SUGGEST

Is @order.add_line_items_from_cart(current_cart) explained someplace?

2010-07-24 164TYPO

D’oh!! Ignore my knucklehead “add_line_items_from_cart” comment.

2010-07-24I moved it closer 172TYPO

Inside the “Joe Asks” box, 3rd para, “has chose” should be either “chose” or “has chosen.”

2010-07-24 121OK

add some explanation of the changes to the functional test here.

2010-07-24"We need to pass a product id on the call to create, and change what we expect for the target of the redirect." 128OK

hadn’t you already handled the ‘wibble’ case:

def current_cart Cart.find(session[:cart_id])
rescue ActiveRecord::RecordNotFound cart = Cart.create session[:cart_id] = cart.id cart
end

it looks like a wibble would be not found, and thus just create a new cart. if not, you could explain why not here.

2010-07-24The screenshot contains the clue: \n \napp/controllers/carts_controller.rb:16:in `show' \n \nWhat's occurring here is that the show method is being called, and the first thing it does is \n \n@cart = Cart.find(params[:id]) 8TYPO

Title for section 19.4 should probably have a comma between Reading and Updating.

2010-07-24 8TYPO

Title for section 21 should probably have at least the first letter R capitalized.

2010-07-24 8OK

In general, chapters with only one section (20, 21, 23) should probably not have a subsection, unless you plan more and the .1 section is just the first written.

2010-07-24These are just placeholders for now 9TYPO

“The changes to Rails … [were] the requirement… and the fact….”

2010-07-24 9TYPO

Remove “to”: “… describing what goes into [to] each.”

2010-07-24 12OK

Too few text lines to justify a page.

2010-07-24Typesetting comes later (see page 1) 15OK

Do the little teasers that start each chapter really have to be bulleted? A single sentence lead-in is a very useful tradition, once in the table of contents to make that an even better guide. Here, though, adding actual bullets for a few words just makes it look like an ill-conceived mini-slide from the book proposal.

2010-11-10 16TYPO

Consider a colon instead of an em dash in “don’t repeat yourself[—][:]every piece of knowledge”, since the second clause defines the term used in the first. The em dashes later in the paragraph are better used.

2010-07-24 40TYPO

“to already-displayed pages in on page 308.” “in on” should be “on”

2010-07-24 93OK

After modifying the test cases as indicated (all previous steps followed) the test cases still do not pass. See below:

kuccello:~/Development/SoldierOfCode/Experiments/depot(iteration-b1) >> rake test
(in /Users/kuccello/Development/SoldierOfCode/Experiments/depot)
Loaded suite /Users/kuccello/.rvm/gems/ruby-1.8.7-p299@global/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
.
Finished in 0.110124 seconds.

1 tests, 1 assertions, 0 failures, 0 errors
Loaded suite /Users/kuccello/.rvm/gems/ruby-1.8.7-p299@global/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
F…..F
Finished in 0.31331 seconds.

1) Failure:
test_should_create_product(ProductsControllerTest) [/test/functional/products_controller_test.rb:26]:
“Product.count” didn’t change by 1.
<3> expected but was
<2>.

2) Failure:
test_should_update_product(ProductsControllerTest) [/test/functional/products_controller_test.rb:45]:
Expected response to be a <:redirect>, but was <200>

7 tests, 9 assertions, 2 failures, 0 errors
Errors running test:functionals!

2010-11-10I can't reproduce this problem 76TYPO

In the bullet list at the top of the page, “updated” should be “updating”

2010-07-25 76TYPO

“type rails followed by the name of our project.” should be “type rails new followed by the name of our project.”

2010-07-25 84TYPO

There are some extra words in “which loads stylesheets from in the public/stylesheets.”

2010-07-25 89TYPO

The first bullet point at the top of the page ends with a period. This is inconsistent with the format of the bullet points at the beginning of all the other chapters.

2010-07-25 90TYPO

“each of the named fields are present” should be “each of the named fields is present”

2010-07-26 90TYPO

“and their contents are not empty.” should be “and its contents are not empty.”

2010-07-26 132OK

At the beginning of 10.3 chapter:

“<%= button_to ‘Empty cart’, @cart, :method => :delete,
:confirm => ‘Are you sure?’ %>”

:confirm => ‘Are you sure?’ doesn’t work (it doesn’t generate any javascript confirm)

2010-07-26The markup it generates in Rails 3.0 looks like the following: \n \n
<input type='submit' value='Empty cart' data-confirm='Are you sure?'/>
\n \nThis data-confirm attribute is processed by /javascripts/rails.js to produce the popup. 39ERROR

The expanded view in figure 2.3 incorrectly has html for an entire page, when in reality it should only have

Hello from Rails!

given that the rest is generated in the application layout at this point.

2010-11-19 144OK

depot_l app to demonstrate Ajax support does not work. I have gone through Troubleshooting points on page 145 and none of them applied. On adding a product, this is what I see in the log:

Started POST “/line_items?product_id=1” for 127.0.0.1 at 2010-07-26 14:16:09 –0700
Processing by LineItemsController#create as HTML
Parameters: {“authenticity_token”=>“DS4HwtXTxypkVH2J+14r17D6DQkFatQtuAgq73l03dE=”, “product_id”=>“1”}

Had it worked, I believe it would have said #create as JS or RJS instead of #create as HTML

Would appreciate if you respond to aminm@fastmail.fm

2010-11-10I can't reproduce this error 29TYPO

“Fully-fledged” is a compound adjective, so should be hyphenated.

2010-08-12 161TYPO

This means that will need to display a Rails template containing a form.

Should probably read:

This means that we will need to display a Rails template containing a form.

2010-08-24 25TYPO

The word “requires” is duplicated first bullet point, second line says “Rails 3.0 requires requires Ruby version 1.8.7…”

2010-08-12 142TYPO

“(by default in the directory as the object being rendered” should be “(by default in the same directory as the object being rendered”

2010-08-24 34TYPO

“This section contains the links and instructions to get that done.” All the following instructions download files and refer to home pages, but don’t specifically mention what files need to change, or compile commands to run per database driver. Changing wording to “links to instructions” seems more correct.

2010-08-12 116TYPO

The first sentence of the page has an extraneous “in”. It reads: In the example above, two products in contain the same title.

2010-08-24 176OK

why the :on => :member ? the resource routing here is not well explained

2010-08-24from previous paragraph "will operate on a member of the collection". 197SUGGEST

on this page you talk about eating our own dogfood by using .salt rather than the salt instance variable. but why do we use var in many other places in the program? it feels like there’s a good little sidebar here that got started but never finished. it’s half explained - just enough to make new ruby devs to say um… wait, what was that again?

2010-08-24 37ERROR

Last paragraph, “If you look at … you’ll see tracing …” I don’t see tracing until I go to one of the application pages, like …/say/hello.

2010-08-12 \n 177SUGGEST

I was keep running tutorial since beginning. When I try to add will_paginate,
bundle install work without problem, but the the OrderController code can’t find Order.paginate method.

This was because I haven’t restarted the server. I think it is better to mention to restart server after bundle install.

2010-11-10 118TYPO

“And because an Cart is declared to have many line items, we can reference them (as a collection) from a cart object:”

Should be “a Cart” not “an Cart”

2010-08-24 61OK

How about footnoting “the PickAxe book” for us beginners?

2010-08-12Covered on page 56. 292TYPO

orders = Orderlast_n_days(7)
should be
orders = Order.last_n_days(7)

2010-08-24 310TYPO

I think there’s a part missing in the last sentence of the introduction:
“Finally, we will cover a few thingssessions, flash, and filters.”

2010-08-24 155TYPO

“Figure 11.3: An error in an layout can affect the entire application” should be “a layout”

2010-08-24 204OK

<%= form_tag do %> seems to give error, while <%= form_tag :login do %> works
thanks

2010-11-12I can't reproduce the problem 55OK

I’m a beginner and do a lot a flipping around to understand what is going on. On page 55 there is a reference to xml builder template starting on page 342. When I click on “342” it brings me to between Chapter 21 “Action View” which hasn’t been written yet and Chapter 22, “Active Resource” with a note that the content will be lifted from Chapter 26 in Ed 3. Is there any way I could have access to Ed 3 or some info that currently isn’t included in my B6.0? Thanks so much! I’m enjoying the process of learning Ruby and RoR thanks to you.

2010-09-09Those chapters are now available. The underlying problem is that the old chapters no longer reflect either best practices or, in many cases, advice that even works with Rails 3.0: \n \nhttp://www.pragprog.com/wikis/wiki/ChangesInRails30 314TYPO

There’s a period missing after this sentence: Note that each route is defined with an optional format specifier

2010-08-24 317TYPO

In the first sentence “The links to the actions that edit an product …” it should say “a product”.

2010-08-24 317TYPO

There’s a second occurrence of “an product” in the first paragraph.

2010-08-24 38TYPO

“creating an simple application” should be “creating a simple application”

2010-08-12 34ERROR

Not sure if this will be fixed with the official release of Rails 3, but ‘rake doc:rails’ fails with “File not Found: lib” - from what I’ve read on this error in forums, I gather that the documentation for Rails 3 either isn’t done or doesn’t install properly? If it’s not fixed by the publishing of the book, it might be wise to mention that.

2010-08-24Fixed in rails rc2 33OK

During this setup process, I installed e-TextEditor, which prompted to install Cygwin, so I did, which royally bit the wax tadpole. Git no longer worked, and I had to do a system restore to get it functioning again. Might put at least a warning about Cygwin, or at most some instructions about getting e-TextEditor to play nice with Git. I just abandoned it altogether.

2010-11-10 22TYPO

“You will find out on on page 262” should be:
“You will find out on page 262”

2010-08-12 38TYPO

“Let’s start by creating an simple application” should be

Let’s start by creating a simple application

2010-08-12 286TYPO

In the last paragraph the text reads
“… starts find_or_initialize_by_ or current_cart will call either new of create …” I think current_cart should actually be find_or_create_by_

David

2010-08-24 226ERROR

The YAML for currency localization on pages 226/7 does not work.

I had to remove the currency: line and then correct the indentation.

2010-11-13Can't reproduce 86TYPO

Middle of the page says "Rails has the ability to import seed data.

To start, we simply create a file in the db directory named seeds.rb"
That file, seeds.rb, is created with the “rails generate scaffold…” command. To add seed data we must modify or add data to that already existing file.

2010-08-12 47SUGGEST

“…that Rails makes available to you as the path to the /say/goodbye path” doesn’t make too much sense to me. It should probably say something like “…that Rails makes available to you containing the path to the goodbye method of the say controller (in this case ‘/say/goodbye’)”

2010-08-12 38SUGGEST

When I Ctrl+C WEBrick in Windows I get “Terminate batch job (Y/N)?” It might be good to mention this, just so it doesn’t come as a surprise. As far as I can tell, it doesn’t matter which you choose.

2010-08-12Fixed on page 82 (where you are asked to stop the server). 62OK

This may be a nitpick, but my brain got stuck trying to figure out the purpose of the code at the top of this page (even though it was just there to indicate the syntax of the “if” structure). Does it actually make sense? I don’t think it does…

2010-08-12 68SUGGEST

First paragraph: “When creating a table, fields defined include…” should probably say “The fields defined when creating this table include…”
My first reaction was that these fields are what should be declared for every table you create… until I realized that didn’t make sense :)

2010-08-12 69OK

It would be GREAT to mention in the sections on “a || b” and “a ||= b” that these shortcuts also support setting values that are not currently defined (“a ||= b” doesn’t throw an error, like you would get using “if !a then a=b end”, which is probably a common mistake in trying to set a default value), and is therefore the preferred syntax for setting a default value (aside from method parameters).

(P.S. Not sure if this is the right page - none of the previous errata displayed here seem to pertain to the page I’m looking at…)

2010-08-12Already covered: "So, count ||= 0 gives count the value 0 if count doesn’t already have a value." 93TYPO

Last paragraph: “We’ll do this using the format_of option” should just be “the format option” - unless I’m missing something (the code sample just uses “format”, not “format_of”).

2010-08-12 96TYPO

The listing of products_controller_test.rb is missing a couple tests after “should create product” - probably should add the rest of the automagical tests (mine has “should show product” and “should get edit”), or at least indicate them with “[…]” or something.

2010-11-10 102ERROR

2nd paragraph outside “David Says” box: “table will be… populated with the new single row for the Ruby book” that’s true - but it will also be populated with entries “one” and “two”, since we left those alone, right?

2010-08-24 148SUGGEST

Troubleshooting - I had an error in my create.js.rjs file which WEBrick reported very nicely in the rails server window, so that may be another place to look.

2010-08-24 27TYPO

In the first paragraph of section 1.2, first sentence, the wording doesn’t read well. I think you wanted to say something like, “While versions of OS X since 10.4.6 (Tiger) have included …”.

2010-08-12 116TYPO

Paragraph: “It’s time to check it all in and move on to the next task, namely, making the
Add to Cart link actually do something!”

TYPO: We have not created any ‘Add to Cart’ link yet. That task takes place on the next chapter.

SUGGESTED CORRECTION: “It’s time to check it all in and move on to the next task, namely, where we’re going to create an fully functional Add to Cart link!”

Hope this helps. I was kind of confused the first time I red it.

2010-08-24 278OK

It reads “The relationship between Orders and Parts through LineItems is an example of such a relationship.” where I think it should be Carts instead of Parts.

2010-08-24That would also be an example, but the example cited also works. 282TYPO

In the last sentence of the last paragraph before 19.4, there is a “to” where a “do” should be.

2010-08-24 309TYPO

The second sentence of that page: “You saw how to create*d*, read, update, and delete this data.”

2010-08-24 318TYPO

there is a third occurrence of “an product” in the paragraph after the first code snippet.

2010-08-24 312TYPO

in the thirt paragraph from the bottom it reads “an product”.

2010-08-24 124SUGGEST

You should explain in deep what the .build method do.
For a newbie like me it was VERY confusing and I had to search on the Internet to finally find out that it was a default behavior of Rails. You didn’t explain it.

2010-11-10 8SUGGEST

What to do when things go wrong.
It would be handy to have a list of things to check when troubleshooting.
Logs, setting debugging levels, strategies to find where the elusive bug is. I’ve spent days looking at what is probably the same bug with a transaction thats backing out and I don’t know why. The error seems to be “undefined method `delete’ for nil:NilClass (NoMethodError)” and there are warnings of shadows variables and previous engine definitions.

It would be nice to have practical advice on how to identify if the problem is with my environment, my code or what I’m trying to make rails do. How can I make the errors more detailed, can I use a debugger, should I insert print statements or increase verbosity?

2010-11-10 133TYPO

The second bullet isn’t being performed and should be removed since the explanation of :notice is done in the 3rd paragraph

2010-08-24 50TYPO

“Ruby on Rails is an MVC framework”. I think it must be only an “a”.

2010-08-12Depends on how you pronounce "m". A google search for "an MVC" produces more results than "a MVC". I leave it as is for now and for the copy editor to verify/correct as necessary. 134SUGGEST

I recommend reworking the first part of this sentence or breaking it in two. It’s in the bullet at the top of the page: “In addition to the wide range of parameters the link_to method we encountered in the templates takes, this method accepts a :notice parameter which will store the specified message in the flash as a notice.”

It just doesn’t read easy and it should ensure any correlation to the link_to method is actually useful - otherwise it’s confusing. I had to read it a few times to make sure I wasn’t missing something.

BTW, in #44460, I meant “3rd bullet” not “3rd paragraph” :)

2010-08-24 135TYPO

The first sentence states, “we have to add a link to the cart and implement an empty_cart method in the store controller.” But we don’t actually get to that in the iteration.

2010-08-24 135SUGGEST

The second paragraph might read easier if you combined the 2 sentences: “… destroy method so it removes …”

2010-08-24 169ERROR

In the explanation of the code changes to orders_controller.rb (1st paragraph) it says “we redisplay the catalog using our redirect_to_index method” when in fact we don’t.

2010-08-24Changed to redirect_to 171OK

Figure 12.3 shows the error_explanation div outside of the depot_form div. In my experience, the instructions place it on the inside. I think it looks better on the outside, but I’m not sure it’s worth the extra steps.

2010-11-10 173SUGGEST

The last paragraph needs more explanation. What is Builder? I see section 21.5 isn’t written yet, but would recommend a link to the section once it’s written. It’s also not clear the relationship between the format.atom call in the action and the atom_feed builder (helper?).

The last paragraph of 12.1 states we’re going to create a “feed of orders” and it’s not clear why we’re jumping into ProductsController. Wouldn’t /orders/history make a better feed address than /products/3/who_bought?

2010-08-24 178TYPO

The code-added-or-changed-on-this-line indicator is missing from the first 2 lines of the index action code snippet.

2010-08-24 196ERROR

This and the previous page (195) state the use of the SHA1 hashing algorithm when we will actually use SHA2 as seen on the next page (197).

2010-08-24 202ERROR

After clicking “Add User”, the index is redisplayed, but without the cheery flash notice. It seems to be missing from the view/layout.

2010-11-12 206TYPO

Figure 14.2 must be recreated since there is no login action in the sessions controller.

2010-11-19 210ERROR

In the 3rd paragraph, “,as we did for the login method” should be removed since there is no login method (and we haven’t whitelisted any yet).

2010-08-24 211OK

In the first paragraph, you might consider a short note reminding the reader they are likely already logged in to the site. So they should restart the browser or the web server to see the redirection since we haven’t implemented logout yet.

2010-11-12 212TYPO

First sentence of Iteration I4: “Let’s start with adding a links to …”

2010-11-12 266TYPO

“profiler” is listed twice. I think the first one doesn’t fit into the alphabetically sorted list.

2010-08-24 211ERROR

In the first code snippet, the :only parameter should include :destroy, not :delete. Otherwise, users will be prompted to login to empty their cart.

2010-11-12 249TYPO

“Now we ready…” should say “Now we’re ready…”. It’s in the middle of the page.

2010-08-24 124TYPO

“we will cover in more detail in on page 132.” remove the “in” after the word “detail.”

2010-08-24 124TYPO

Screenshot error. After you have added the first line item to the cart the cart will have the new style that we did in the previous chapter. The screenshot shows a vanilla page that has none of the styling.

2010-11-14 142ERROR

“That means our partial will be stored in the file _line_item.html.erb in the app/views/line_items directory.” – The partial file is not created automatically.

2010-08-24 156TYPO

The whole test code for “should create line item via ajax” is new to the file, but there are only triangles on some of the lines.

2010-08-24 21TYPO

The first sentence of the third complete paragraph seems to contradict the third sentence in the fourth paragraph of the “Preface to the Fourth Edition” (page 13): “But the biggest change is in the final section: as it is no longer practical to cover the entire ecosystem of Rails….”

2010-08-12 51TYPO

In the second-to-last sentence on the page, you have, “… and the product_id identified a product.”. This doesn’t read well to me. It seems that it would be better if it was, “… and the product_id of a product.”

2010-08-12 164TYPO

Missing triangles.

2010-08-24 165TYPO

Missing triangles.

2010-08-24 114TYPO

“we use these commmon Ruby idioms…”

commmon -> common

2010-08-24 189ERROR

The order_shipped test will fail with an error at this point, if you’ve only been following along with the code in the book and not downloading mailers/notifier.rb. The method order_shipped hasn’t yet been defined to take an argument, which is passed from the test.

2010-11-12 88OK

In the new HTML for index.html.erb, it would probably look better if the link to new product on the bottom of the page had the word “product” capitalized.

2010-08-12 89TYPO

In the last paragraph, you talk about how we edited application.html.erb to include a link to depot.css. The generated application.html.erb file already contained the line “<%= stylesheet_link_tag :all %>” so we didn’t need to edit it.

2010-08-12 176SUGGEST

curl is not installed by default on Windows, afaik. Would it make sense to add curl to the Installing on Windows section?

2010-08-24 62SUGGEST

The paragraph starting with “A block must appear after the call to a method” isn’t clear to me. I’m not entirely sure what this is trying to tell me, since I see other examples where a block clearly isn’t preceded by a call to a method. Can you provide some clarification here?

2010-08-12 121SUGGEST

In the first sentence after the product.rb code listing, you use present tense for “declare” but past tense for “defined”. It would probably read better if both were present tense or both were past tense.

2010-08-24 121TYPO

In the third paragraph of section 9.3, last sentence, you refer to the source file for the line items controller without the “.rb” extent. It should be, “… method in app/controllers/line_items_controller.rb, …”

2010-10-03 122TYPO

In the second to last paragraph, third sentence, you refer to the line items controller file without the “.rb” extent. It should be, “See the comments inside the app/controller/line_items_controller.rb file …”

2010-08-24 161TYPO

In the code for test “requires item in cart”, all the lines for this test should have a triangle to the left since it is a new test.

2010-08-24 166TYPO

In order fixture one, there should be triangles next to the name and email fields in addition to the one for pay_type.

2010-08-24 167ERROR

In the sentence before the order.rb code that adds the has_many relationship, it says that the :dependent attribute means the line items will be destroyed when the “cart” is destroyed. Should that be “order” instead of “cart”.

2010-08-24 170OK

The line_items.yml file at the top of the page is identical to the one on page 167 and it seems redundant to talk about the fixture and list the fixture source here.

2010-08-24No, on page 170 one line is modified (cart => order). This change is indicated with a triangle. 67TYPO

Last sentence in the second paragraph of 4.5 needs some attention.

2010-08-12 173TYPO

The who_bought method is being introduced for the first time. There should be triangles before all lines.

2010-08-24 178OK

In order for the “bundle install” command to work, the user may need root privileges. You should probably add a footnote about that.

2010-11-10 179SUGGEST

After making the changes for will_paginate, I had to stop and restart the rails app for the changes to take effect. Maybe you should mention this before telling the user to try it. Before I did that, I got the following error:

NoMethodError (undefined method `paginate’ for #):
app/controllers/orders_controller.rb:5:in `index’

After stopping and restarting the server, everything worked.

2010-10-18 179TYPO

In the paragraph after the code listing for index.html.erb, second sentence, you have repeated the word “than”.

2010-08-24 179TYPO

In the paragraph after the code listing for index.html.erb, third sentence, you have used the word “specify” instead of “specifies”. It should read, “The controller specifies the number of …”

2010-08-24 189OK

In order for the functional tests to pass, you need to add a line to the line_items.yml fixture file to have a line item for order one that has the Ruby 1.9 product.

2010-11-12This was done on page 170 34ERROR

Has already been mentioned, but when I do rake doc:rails, I get:

rake aborted!
Don’t know how to build task ‘README.rdoc’

2010-08-24Fixed in Rails 3.0 RC2 200TYPO

Second line, “fields” should be “field”.

2010-08-24 193ERROR

The test assertion for the From: header does not match the code on page 184 where the default from is set to from@example.com. You should update the original code or update the test so they match.

2010-11-12 202TYPO

The “Add User” button actually shows up as a “Create User” button.

2010-08-24 204SUGGEST

It would probably be a good idea if the login form displayed the alert message if the previous login failed.

2010-11-12 210TYPO

In the sentence after the application_controller.rb listing, there are two periods on the end of the sentence.

2010-08-24 211OK

After making all the changes described in section I3, the integration test still fails.

2010-08-24 211OK

Please ignore erratum #44607. I had a typo in the skip_before_filter statement in the orders controller. Sorry for the false alarm.

2010-08-24 224ERROR

The translation key for the “Add to Cart” button needs to be named add_html since there is a HTML entity in the spanish version.

2010-11-13 225OK

For the cart translations, you should also translate the confirm text. Since the spanish will have a leading upside down question mark as well as an a acute, it will need a trailing _html in its name.

2010-11-13 228TYPO

In the english translation for the legend, the word “your” should be capitalized as it was in the pre-translation template file.

2010-11-13 229ERROR

In the spanish translation, the address and pay_prompt strings both contain html entities. These keys should end in _html.

2010-11-13 230ERROR

In config/locales/es.yml you have left out the lines that translate activerecord.models.order. It should be:

  activerecord:
    models:
      order:  \t   "pedido"
    errors:
      messages:
        inclusion: "no est&aacute; incluido en la lista"
        blank:     "no puede quedar en blanco"
  errors:
    template:
      body:        "Hay problemas con los siguientes campos:"
      header:
        one:       "1 error ha impedido que este %{model} se guarde"
\tother:     "%{count} errores han impedido que este %{model} se guarde"
2010-11-13 231TYPO

In the code for _form.html.erb, in order for the output to look like figure 15.8, you need to add the following line right before the