By Developers, For Developers

Historical errata for Agile Web Development with Rails 5.1

tag after the if and else?

tag matches the tag.
PDF PgPaper PgTypeDescriptionFixed onComments
81TYPO

In the PDF download, on page 81, the download links lead to 404’s. It’s possible the links are the same on other formats but I have not checked.

media.pragprog.com/titles/rails5/code/rails51/depot_a/db/seeds.rb
media.pragprog.com/titles/rails5/code/rails51/depot_a/app/assets/images/

2017-05-28
viiiSUGGEST

Shouldn’t the text
And Rails 5.0 is no different

be replaced with the current version (ie):
And Rails 5.1 is no different

2017-05-31Changed to Rails 5
ixSUGGEST

During the ten years since its initial release…..

maybe a small detail but since the first release (0.8.0 in rubygems - October 2004), there are more than ten years.

2017-05-27I've updated the number to eleven. Counting of years in Rails typically starts with the 1.0.0 release on December 13, 2005.
93ERROR

“After making this change, we rerun the tests, and they report that all is well.”

Actually, at this point one of the tests fails (below), because test/fixtures/products.yml has “MyString” for the image_url attributes. This doesn’t get fixed until PDF p. 99

Error:
ProductsControllerTest#test_should_get_index:
ActionView::Template::Error: The asset “MyString” is not present in the asset pipeline.

2017-05-31
199TYPO

Command line to launch foreman is misspelled “forman start -p 3000”, the “e” is missing in foreman.

2017-05-28
210SUGGEST

The react code adds the and wraps the element in a div. This is noted in the paragraph below but it may be nice to highlight the changes, particularly the in the code sample.

I missed this and had to go back and debug my react code to figure out why it wasn’t rendering but also not throwing any errors.

2017-05-31Unfortunately, the current set of tooling either lets us highlight too much or too little. We will go with too much in the next beta.
204TYPO

Mismatched double- and single-quote here:

<select id=“pay_type’ name=”order[pay_type]">

2017-05-31
6SUGGEST

update for rails 5.1.1

$ sudo gem install rails —version=5.1.0 —no-ri —no-rdoc

should be

$ sudo gem install rails —version=5.1.1 —no-ri —no-rdoc

2017-05-27
7SUGGEST

update for rails 5.1.1

$ sudo gem install rails —version=5.1.0 —no-ri —no-rdoc

should be

$ sudo gem install rails —version=5.1.1 —no-ri —no-rdoc

2017-05-27
12SUGGEST

update for rails 5.1.1

$ sudo gem install rails —version=5.1.0 —no-ri —no-rdoc

should be

$ sudo gem install rails —version=5.1.1 —no-ri —no-rdoc

2017-05-27
13SUGGEST

update for rails 5.1.1

$ sudo gem install rails —version=5.1.0 —no-ri —no-rdoc

should be

$ sudo gem install rails —version=5.1.1 —no-ri —no-rdoc

2017-05-27
14SUGGEST

apt-get install can be replaced with apt install (as used in previous page at the beginning).

2017-05-27
14SUGGEST

update for rails 5.1.1

$ sudo gem install rails —version=5.1.0 —no-ri —no-rdoc

should be

$ sudo gem install rails —version=5.1.1 —no-ri —no-rdoc

2017-05-27
15SUGGEST

update for rails 5.1.1

$ sudo gem install rails —version=5.1.0 —no-ri —no-rdoc

should be

$ sudo gem install rails —version=5.1.1 —no-ri —no-rdoc

2017-05-27
15SUGGEST

Before being able to install yarn on Ubuntu 16.04 you will need to do the two additional steps described in the yarn installation (yarnpkg.com/lang/en/docs/install/) to add the yarnk key and repository

2017-05-27
15SUGGEST

to install chromedriver in Ubuntu the

sudo apt install chromedriver

should be

sudo apt install chromium-chromedriver

2017-05-27
16SUGGEST

update for rails 5.1.1

replace the two references for 5.1.0 with 5.1.1

2017-05-27
24SUGGEST

rails 5.1.1 update

If you get a Rails version other than 5.1.0

should be

If you get a Rails version other than 5.1.1

2017-05-27
25SUGGEST

rails 5.1.1 update

Rails 5.1.0 application

should be

Rails 5.1.1 application

2017-05-27
199TYPO

“forman start -p 3000”

should be “foreman” with an “e”

2017-05-28
73SUGGEST

Shouldn’t the output of the command ls -p be something like the following (default alphabetical order) ?

app/ bin/ config/ config.ru db/ Gemfile Gemfile.lock lib/ log/ package.json public/ Rakefile README.md test/ tmp/ vendor/

2017-05-31
75SUGGEST

In the scaffold file generation the

test/helpers/products_helper.rb

has been replaced (in 5.1.1) with

test/system/products_test.rb

Or is this a bug?

2017-05-31
77SUGGEST

Rails 5.1.0 application …

should be replaced with

Rails 5.1.1 application …

and

  • Listening on tcp://localhost:3000

with

  • Listening on tcp://0.0.0.0:3000
2017-05-31
14SUGGEST

the following line

$ sudo apt-get install apache2 curl git libmysqlclient-dev mysql-server nodejs

can be replaced with:

$ sudo apt install apache2 curl git libmysqlclient-dev mysql-server nodejs

apt install instead of apt-get install as used elsewhere

2017-07-01
1SUGGEST

Throughout the book, you use the words “simply”, “easy” and “just”. I’m a seasoned programmer, not a newcomer, but even so it’s jarring and a bit irritating to have the suggestion that something is trivial or simple. I wouldn’t be reading a technical book if the knowledge it contained was entirely self-evident. This is an amazing book and I think it would be even better without being jolted out of the flow with these throwaway terms. Thanks!

2017-06-29
58TYPO

`self.where(‘paid = 0’)` should be `self.where(‘paid == 0’)`

2017-06-11
58SUGGEST

Ignore my last suggestion! SQL!

2017-06-11
100TYPO

“remaing”, last para.

2017-06-11
108TYPO

<%= csrf_meta_tags %> repeated twice

2017-06-11
169TYPO

repeated “with”, line 4 first para.

2017-06-11
196TYPO

“becuase” in para that begins “Webpacker”.

2017-06-11
197TYPO

first para, ‘saved as’ instead of ‘saved us’

2017-06-11
77OK
  • Listening on tcp://localhost:3000

should be replaced with

  • Listening on tcp://0.0.0.0:3000
2017-06-17What is shown depends on your OS and other settings. What the book shows is what my machine shows. Practically, it won't matter, but if this creates some problem that we aren't aware of, please post another one (that is more specific) or try us in the forums.
82ERROR

Image lorem.jpg has 0 size in the web page, tgz and zip files.

2017-06-11
47TYPO

Hi,

The templates are badly referenced. Instead of the related chapters (as clickable link) the text “the (as yet) unwritten …” is written in read. Regarding older version the first template could reference “Generating HTML with ERB” and the last one could reference “Generating XML with Builder”.

2017-07-21
81TYPO

Hi,
The same error (than page 47) about reference error. Here based on previous version the link should be referenced to “A Stand-alone Application Using Active Record”. Instead the same placeholder text in red is present.

2017-07-21
98TYPO

In the third line of the page, there is a reference to the older ‘rake test’ instead of ‘rails test’

2017-06-11
98ERROR

The third “row” added in the fixtures named “ruby” has for its image_url attribute the value ruby.png…
Since this file is not present in the “assets/images” folder, this will raise an extra error later on (test performed on page 101).
Instead of having two errors we got three.
Either providing an image named ruby.png or changing the fixture with the value “rails.png” (a picture with that name is present) will do the trick.

2017-06-11
114TYPO

The fixture listing was modified earlier (on page 98). Here since it’s just a reminder there is no need to put the modification marks (arrows on the left).

2017-06-11
115ERROR

Hi,
The link to the assertion documentation is broken.. This could be a typo error..
But actually I was unable to find any “SelectorAssertions” class or "assert_select_ method on the rails 5 API (or in the edge API).
When manually browsing in a previous version of rails (eg. v4.1 like api.rubyonrails.org/v4.1/classes/ActionDispatch/Assertions/SelectorAssertions.html ).
Does this mean that Selector Assertions are no longer supported?
Although the test code is working with rails 5.1…

2017-06-11
117ERROR

Hi,

I tried the caching mechanism.. And the console should normally log as stated in the book some “Read fragment..” and “Write fragment..” lines.
Nevertheless, I was unable to get those logs.. Indeed I asked myself if the caching actually worked.

After many investigation ( I tried from scratch with a rails 5.0 app) and indeed those lines are logged out. But not with the version 5.1 of rails..

But I’m still wondering if caching really work?

The only clue I have is that when caching occurs there is only one DB request which is actually the count request regarding the timestamp.. So I can confirm that at database level caching occurs, but since those lines about reading and writing fragments (fragment views indeed) I’m not sure about the view caching which is the most important here regarding the delays.

2017-06-11
85SUGGEST

Extra blank space inside the
tag at bottom of listing.
Previous tags do not have extra space on the same listing.

2017-06-11
94SUGGEST

The following

…..
Finished in …
5 runs, 23 assertions, 0 failures, 0 errors, 0 skips

should be

.
Finished in …
1 runs, 5 assertions, 0 failures, 0 errors, 0 skips

2017-06-11
117ERROR

Continued..
I dove in some many resources and finally I figure out that Rails 5.1 introduced a new config parameter that actually need to be set (by default is false) in the config file in order to be able to view the cache logging.

E.g: config.action_controller.enable_fragment_cache_logging = true

Maybe it’s worth adding this detail.

2017-06-11
119TYPO

In the second paragraph of the section ‘Iteration D1’, the following sentence “Every time a request comes in, we can recover the identity from the session …” has ambiguity with the word “identity”. I think that, as in the previous sentence the word “identifier” is more suited.

Nevertheless, I’m non native english so this remark may be irrelevant.

2017-06-11
200TYPO

bin/webpack instead of bin/wepack

2017-06-11
xvTYPO

Pedantic note. The first bullet point in “Who This Book is For” starts with “Introduced in Rails 5, Turbolinks”…

Turbolinks was introduced in Rails 4, with the gem renamed to turbolinks-classic and the new version named Turbolinks 5.

2017-06-17
1ERROR

/forums/470/topics/15017#42487 Turbolinks, navigating back, and the react components don’t mix. Need to key off of the turbolinks event or disable turbolinks on this page or something.

2017-06-30
158ERROR

Hi,
I think that this error is quite big…
In page 158, after adding the “bit of ajax”, Sam asks “Does it work?” but it sure does not.
Just because jquery is not installed by default in Rails 5.1. The browser developer console confirm that ‘$’ is not defined.
I don’t know how to install Jquery and get the ajax part working.
Should I add a hard-written script tag including the jquery package in the application layout view?
Should I use some ‘javascript_include_tag’ helper?
Should I use the Gemfile?
Should I use the yarn package tool?

I bought that book specifically because it seems to deal with rails 5.1 and its supposed new way of managing the asset pipeline, but until now I don’t learn anything at all (except installing yarn in the first chapters which is not really something unable to do by itself).
I have a book but I’ll still googling for a while..
Though I know that the book is in Beta…

2017-06-17
174TYPO

The reference to the chapter related to a plugin that handle Credit Card processing is absent.

2017-07-21
177ERROR

The listing at the top of the page seems to be erroneous..
There are some trailing characters <%#>.
And the closing

is shown commented.

2017-08-18
188TYPO

In the second to last paragraph the word supplies is written with 3 ‘p’ (suppplies)

2017-06-17
198TYPO

In the 5th paragraph there is a mention to the ‘Rake’ task.
Maybe reference here ‘Rails’ task for consistency.

2017-06-17
92ERROR

The updated Product model containing the newly defined validations appears to be inaccurate. In this figure, the model lists the :image_url presence to be true, but later lists the :image_url, allow_blank: true.

I believe the former should be removed. Hope this helps!

2017-06-17This is intentional, but it's hard to miss why. On that same page: \n \n> Note that we use the allow_blank option to avoid getting multiple error messages when the field is blank.
135SUGGEST

Add spacing around > sign in quantity > 1 (both in the comment and the where)

2017-06-17
158ERROR

The javascript still does not work even after installing jquery-rails in Gemfile and restarting the server.
The following needs to be also added to app/assets/javascripts/application.js:
//= require jquery
//= require jquery_ujs

There is also another sqlite3 error, maybe when trying to click too fast (dev environment too slow)?

Completed 500 Internal Server Error in 5048ms (ActiveRecord: 2.6ms)

Completed 500 Internal Server Error in 5063ms (ActiveRecord: 5032.7ms)

ActiveRecord::StatementInvalid (SQLite3::BusyException: database is locked: UPDATE “line_items” SET “quantity” = ?, “updated_at” = ? WHERE “line_items”.“id” = ?):

ActiveRecord::StatementInvalid (SQLite3::BusyException: database is locked: commit transaction):
app/controllers/line_items_controller.rb:33:in `block in create’
app/controllers/line_items_controller.rb:32:in `create’

app/controllers/line_items_controller.rb:33:in `block in create’
app/controllers/line_items_controller.rb:32:in `create’

2017-07-02Added a mark to indicate that the require jquery line was new
160TYPO

Now that we have the jQuery-UI libraryjQuery-UI library available …..
We do that by adding two lines to app/assets/javascripts/application.js

But on page page 161, only one line is indicated as new:
//= require jquery-ui/effects/effect-blind

2017-07-02
161OK

should indentation be used in the _line_item.html.erb code listing for the lines with the

2017-07-02The indentation of the
164ERROR

Running ls -p app gives us eight folders and not six. The channels and jobs are missing

2017-07-02
173ERROR

Note that we didn’t specify any data type for three out of the four columns.

this should be two out of the four as address:text and pay_type:integer

2017-07-02
174OK

AddOrderIdToLineItem: migrating =
— add_column(:line_items, :order_id, :integer)
-> 0.0008s
AddOrderIdToLineItem: migrated (0.0009s)

should be (add_reference, foreign_key):

20170628162816 AddOrderToLineItem: migrating =
— add_reference(:line_items, :order, {:foreign_key=>true})
-> 0.0088s
20170628162816 AddOrderToLineItem: migrated (0.0092s)

2017-07-02That's not what I see when I run the commands.
175SUGGEST

“Checkout” used with double quotes
‘Empty cart’ used with single quotes

2017-07-02
224ERROR

Hi,
The listing here seems to be the one for performing a job for the payment not for sending an email.
Unfortunately, this prevent to keep going in the tutorial.

2017-07-02
226OK

It seems to lack fixtures settings in order to link the line item to the order. By adding eg. “order: one” now the tests pass.

2017-07-03This should have been done on page 181.
229OK

Hi,
In this listing the first require actually seems to need to add the required library as a gem (gem ‘activemodel-serializers-xml’).
Also, there is no clue about why this is necessary..

2017-07-03Those lines would have been added if you did the playtime exercise on page 190. If you chose to skip that step: no problem.
229ERROR

Hi,
It seems that here the method’s name should be “charge!” and not “make_payment”.

2017-07-03It's deliberately weird and different from the method we implement in Order to stress the fact that we are integrating with a third party.
241ERROR

Hi the link to the Rails library is “slightly” outdated, it points to the version 3.2 of Rails.

2017-07-02
181SUGGEST

When trying to run the tests there is an error:

ActiveRecord::Fixture::FixtureError: table “line_items” has no column named “order”.

On page 181, there is a mention that we would need to change all references to products and carts if the optional exercises are not done.

By changing the following fixture in test/fixtures/line_items.yml from

two:
product: ruby
order: one

to

two:
product: ruby
order_id: 1

the tests should be passing again.

2017-07-21When I run tests out of the downloaded code in depot_p, I get a failure around a missing method that we add in the following section, but the error you describe doesn't happen for me. Can you post in the forum if you are having this problem, and maybe a link to your in-progress code?
7ERROR

The command for installing ChromeDriver is denoted as:

$ sudo apt install yarn chromedriver

However, the package name has changed. Using the default vagrant box from the rails/rails-dev-box git repo (Ubuntu 17.04), the command to use would be:

sudo apt install yarn chromium-chromedriver

2017-07-21
25ERROR

The command “sudo apt install yarn chromedriver” failed.

Instead I ran “sudo apt install yarn chromium-chromedriver”

2017-07-21
108ERROR

Hi,

In the screenshot of the page 240 we can see for the first time the title (Pragmatic Bookshelf) appearing in the header of the page. How this title is set by the instance variable (@page_title) is explained but where this instance variable was not explained.

Where should we set that instance variable ? I guess that could be in application_controller.rb but not sure if this is the best way.

Moreover it seems that we can also set a default value right in the view as it’s supposed to be when we look at page 397 (something like that: <%= @page_title || “Pragmatic Bookshelf” %>)

2017-08-18
173160TYPO

“Install thes gems” should read “Install these gems”.

2017-07-21
208197TYPO

“this saved as a ton of time and aggravation” should read “this saved us a ton of time and aggravation”.

2017-07-21
181165TYPO

“doesn’t even ned an ending tag” should read “doesn’t even need an ending tag”.

2017-08-18
98TYPO

In products.yml fixture file the book ‘ruby’ should have ruby.jpg instead of ruby. png, because the file name in images directory is ruby.jpg. This issue is triggered when the bin/rails test is running, after the update of products_controller_test.rb as described on page 101.

2017-08-18
92TYPO

The {..} hashes sometimes have extra spaces, sometimes not.
On page 92 there aren’t: validates :price, numericality: {greater_than_or_equal_to: 0.01},
while on page 101 there are: post products_url, params: { product: @update }
In the latter case only the product: … value is replaced, but it’s better to change formatting if it is necessary - if it is not consitent with other parts of the code.

2017-08-18
184168TYPO

The URL “coffeescript.org” has broken over two lines and been hyphenated as “coffee-script.org”. This URL leads to a Chinese site. Would suggest marking the URL style as non-hyphenatable to avoid this confusion — the hyphenated site looks like a translation of the official one, but it could easily be malicious.

2017-08-18
199183SUGGEST

The line “sqlite3 -line db/development.sqlite3” can be replaced by “rails dbconsole”, which is a useful command to know as it also works with other database engines :)

2017-08-18
7ERROR

The current rails-dev-box.git doesn’t work with the libvirt backend - I changed it to use wholebits/ubuntu17.04-64 but it needed additional packages to get ‘gem’ working. In addition chromedriver is now chromium-chromedriver.

2017-08-18
1ERROR

test/capybara issue outlined in /forums/470/topics/15236/posts/new?

2017-08-18
237222SUGGEST

The use of mail.body.encoded in the test for the HTML part of the email (in the “shipped” test) is not a great idea if you have non-US-ASCII characters in the mail (say, you had typed the times character directly rather than using ×) as you cannot test without knowing its encoded form. It would be better to test the HTML against mail.html_part.body.decoded, especially as this can’t be tricked by something in the text part :)

2017-08-18This is what the Rails generator produces, and it's one less thing to have to explain to the reader about changing. We're trying to stick to what Rails does by default, but I do take your point.
240225ERROR

The code as provided does not run; either jobs/charge_order_job.rb needs to call order.make_payment or models/order.rb needs to define charge!(pay_type_params) rather than make_payment(pay_type_params)

2017-08-18
288273ERROR

The code for the locale switcher includes `javascript_tag “$(‘.locale input’).hide()”`, but this requires jQuery, which is no longer included in the application.

2017-08-17
186SUGGEST

Products have many line_items, and line_items belongs to an order.

should be (line_items is plural)

Products have many line_items. and line_items belong to an order.

2017-08-18
187SUGGEST

ActiveRecord::HasManyThroughSourceAssociationNotFoundError (Could not find the source association(s) “order” or :orders in model LineItem. Try ‘has_many :orders, :through => :line_items, :source => ’. Is it one of product or cart?):

This is because the belongs_to :order is missing from the line_item model.
Maybe because this was added in one of the exercises?

As a general note it would be good, if possible, to have the code working even when the additional exercises are not completed.

2017-08-18That association is added on page 180.
192SUGGEST

the command bin/rails webpacker:install fails with the following message

Node.js not installed. Please download and install Node.js (node_url)

even though nodejs was installed in previous chapters.
It turns out that the version installed was 4.2.6 (nodejs —version).

Following the instructions in nodejs installation:
curl -sL (url_here with http) deb.nodesource.com/setup_6.x | sudo E bash
sudo apt-get install -y nodejs

installs version 6.11.1 and then the webacker:install works.
This is on Ubuntu 16.04.2

2017-08-18
304290OK

The three ‘role’ lines only work if the username on the deployment server is the same as on the server you are deploying from. It would be better to replace the three lines with this:

server domain, roles: %w{web app db}, user: deploy_user, primary: true

where deploy_user is a variable containing the username on the deployment server. If not, there should be a prominent warning that this setup will only work if the two usernames are the same, and there should be a link to a more comprehensive setup guide.

2017-10-07While there are indeed many ways in which the target environment could be different than the development environment, going down the path of trying to describe each would require a full book. This chapter is only meant to describe enough to (a) get you started, and (b) get you to the point where you know enough to ask and look for the answers to the right questions.
308294SUGGEST

Iteration L3 ends with the paragraph “Although our job is just starting when we first deploy our application to pro- duction, we’ve completed our tour of the Depot application. After we recap what we did in this chapter, let’s look back at what we’ve accomplished in remarkably few lines of code.” This probably needs to be moved to the end of L4.

2017-08-18
29SUGGEST

In the diagram showing file structure the hello.html.erb file is pointing to a block that contains the generated html instead of the erb file content. This might be confusing to a reader who is yet unfamiliar with how the html is created.

2017-08-17
163TYPO

Hello.

Seems like tiny typo on page 163 pdf

—->
If you look in the app directory, you’ll find six subdirectories:
depot> ls -p app
assets/ controllers/ channels/ helpers/
jobs/ mailers/ models/ views/
<—-

Apparently, there are eight subdirectories.

2017-08-18
108TYPO

rails51/depot_e/app/views/layouts/application.html.erb’s newly added HTML elements:

around the previously added

..

element and while the closing element should be

, in the B6.0 version it is

.

2017-09-10
2SUGGEST

Before installing the ChromeDriver package, I suggest that you recommend updating the package lists with sudo apt-get update. I was not able to install ChromeDriver until I performed this step.

2017-09-10
90TYPO

the image for the new page is showing a value in the price, (0.0) which would only show up in the page if there was a default and at least in the process i have used so far this has not been added… or the user had typed 0.0. also, if price is blank “Price is not a number”, takes priority over “Price must be greater than or equal to 0.01”

yes, nitpicky. what can i say…

2017-09-10The screenshot is generated from the actual code produced in the book.
225TYPO

We haven’t declared a construtor yet,

should be

We haven’t declared a constructor yet,

2017-09-10
223SUGGEST

I think

There is no reason to remove id element.

2017-09-10adding ids is usually considered a bad practice, because it means you cannot use the markup on another page that might be using that id. Although Rails does add them, there is no benefit to doing so, since we aren't using them to locate DOM elements or style.
111TYPO

I could be wrong because I am new to coding, but the text here says:

“… an img selector is nested inside the #banner selector. Also, an a selector is inside the #side selector.”

Out of the four selectors mentioned in those sentences, the only one I see in the code I read and copied out of the book is the “a” selector. I do not see “img”, “#banner”, or “#side” selectors in the snippet of SCSS we wrote in the “application.scss” document mentioned in this section of the book. I did not download the source, so I don’t know if it matches the book or not.

Again, I’m a new coder, but I’m pretty confused here.

2017-09-10
142ERROR

There is a sentence: “Invalid carts aren’t our biggest problem here; we also want to prevent access to other people’s carts.”

If I understand correctly, preventing :cart_id from line item URL prevents only manipulating someone else’s cart.

Unfortunately it doesn’t prevent access someone else’s cart, as for instance my cart ID is 7, but I can see the previous cart: localhost:3000/carts/6
The necessary change is to check whether the cart ID in the URL matches the cart ID belongs to the current session.

2017-09-10
146TYPO

cart/show/html.erb: HTML element mismatch, in the PDF:

Total:

It should be

2017-09-10
154ERROR

The cart’s partial template (rails51/depot_j/app/views/carts/_cart.html.erb) contains the representation of the notice, even if it is shown by show.html.erb, and the text also mentions that the notice is not used here: “This is basically our carts/show.html.erb
template but using cart instead of @cart, and without the notice.”.

2017-10-07I'm not following the problem here. I looked at this part of the book and it looks correct/intentional to me.
159SUGGEST

Indentation missing after the <% if @cart %>

2017-10-07Can't find this issue on the given page or near it.
166SUGGEST

Indentation missing after <% if line_item == @current_item %>

2017-10-07I can't find where this issue exists. It's not on the given page.
169SUGGEST

parens

should be

parentheses

2017-10-07"parens" is allowed by our style guide and is a legit word: http://www.dictionary.com/browse/parens
177SUGGEST

Missing identation inside

for the buttons.

2017-10-07I can't see where the indentation is messed up
177SUGGEST

Should the code for the controller (in the link) have two different private sections?
Wouldn’t it be better to all be under one private section?

2017-10-07Both the code download from the .zip and the link only have one private section that I can see.
188SUGGEST

The default display for SQLite version 3.11.0 when running a quer is different from the one displayed on the book.

ie. it is one line without any headers

sqlite> select * from orders;
1|Dave Thomas|123 Mill St|customer@pragprog.com|0|2017-07-03 18:16:38.179019|2017-07-03 18:16:38.179019
2|Phil Jones|123 Somewhere str|phil@example.com|0|2017-09-14 10:12:14.592338|2017-09-14 10:12:14.592338

2017-10-07
442TYPO

“After you bundle install, there is a new generator available that will set up RSpec for you:
> bin/rails generate spec:install should be rspec:install
create .rspec
create spec
create spec/spec_helper.rb
create spec/rails_helper.rb”

2017-10-07
1ERROR

See /forums/470/topics/15492#43428 text indicates tests are passing, but they are not

2017-10-07
11TYPO

/forums/470/topics/15495#43436

2017-10-07
181SUGGEST

Indentation missing after

for ‘Empty cart’ and ‘Checkout’ buttons
(previously reported for page 177, but numbering has changed in B7.0)

202203SUGGEST

You should mention that the server needs restarting after installing webpack and co…
Failure to restart the server before testing the <%= javascript_pack_tag(“hello_react”) %> in the browser will result in an error that will confuse new programmers.

94ERROR

Two things: if you just run the tests, there are lots of errors from the controller test. You might hint for that to prevent confusion, if the reader just retypes the “main” test command (or uses the command history).

Second: when you run JUST the model tests, you get a failure in product_test.rb line 11 because a blank image_url is tolerated and when you create a new product I suppose the image_url is empty.

113TYPO

English is not my first language, so I am not really sure…
In the third paragraph, you wrote “The page design is fairly minimal, though we’ve added a lot of padding, mar- gins, and other specing directives to ensure a decent layout for the side nav and main content.”

Shouldn’t it be “and other spAcing directives”…?

217SUGGEST

the link for the code for orders_controller.rb has two private keywords (lines 81 and 93).

136ERROR

`current_item.quantity += 1` no method error
`NoMethodError: undefined method `+’ for nil:NilClass
\tfrom app/models/basket_item.rb:8:in `add_product’
\tfrom (irb):2`

The same occurs in my remove_one method which looks like this

` def remove_one
puts(quantity)
quantity -= 1
if self.quantity < 1
self.destroy
else
self.save
end
end`

The solution is to ensure that a reference to self is used so
`quantity -= 1`
and
`current_item.quantity += 1`
become
`self.quantity -= 1`
`self.current_item.quantity += 1`

This may be an issue with the latest version of rails or Ruby. Or maybe an intentional change.
I am running Rails 5.1.4 and Ruby 2.4.2
I am sure others will be too.

225SUGGEST

The smtp setup should be inside the existing `Rails.application.configure`
The implication with the code in the pdf is that a new section
`Depot::Application.configure do`
Should be created to contain the action mailer configuration.

It’s just a little confusing

245ERROR

On page 245 of the pdf you state

"To improve the appearance of the page, we add
and

tags."

These are not shown anywhere and are not added so you need to either drop that statement or update the _form.html.erb code to include those

249ERROR

On page 249 of the pdf you state the following

This form is different from ones you saw earlier. Rather than using form_with ,
it uses form_tag

And the code does show that, however form_for and form_tag are being deprecated in favour of form_with and the code should be updated to use form_with rather than form_tag

140ERROR

If you just change the assert_select to the new line item titel it will fail, since it finds the li from the ‘.side_nav’ navigation.
I suppose you have to nest the li to maybe ‘.carts li’…

151TYPO

In the last sentence i found “…any cart other than than one currently…”.
I think it should be “…any cart other than THE one currently…”

151TYPO

On the first block of text it goes „Next. we …“
I think there should be a comma after Next instead of a point.

255SUGGEST

On page 255 of the pdf when discussing tyhe integration test setup you state
“Note that the setup() method will call login_as() only if session is defined.”

That statement needs clarification. How is it only called if a session is defined?

226SUGGEST

If you’re thinking to yourself that this looks like a controller, that’s because it does.

wouldn’t it be better as the following?

If you’re thinking to yourself that this looks like a controller, that’s because it is.

149TYPO

On the second line of the page I think the reference to “…/carts.css” is missing an S as in “…/carts.scss”

7ERROR

` sudo apt install yarn chromedriver`
fails with rails-dev-box.git / vagrant with: -

"ubuntu@rails-dev-box:~$ sudo apt install yarn chromedriver
Reading package lists… Done
Building dependency tree
Reading state information… Done
Note, selecting ‘cmdtest’ instead of ‘yarn’
Package chromedriver is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package ‘chromedriver’ has no installation candidate"

13xiTYPO

In the last paragraph, second to last sentence, the first occurrence of “which” should be “with”. It should say, “Rails 5.1 brings Webpacker, with a preset configuration for Webpack, …”.

5029TYPO

In the paragraph after the “Dynamic Content” heading, third sentence, there is an extra word “is” before the word “named”. It should say, “That’s the template file named hello.html.erb; …”.

103TYPO

The Rails helper method called does this by setting the CSS class of each row to either list_line_even or list_line_odd, automatically toggling between the two style names on successive lines.

The name of method (word ‘cycle’) is missing.

233SUGGEST

Adding the line
require ’active_model/serializers/xml

in app/models/order.rb

also needs the gem to be installed.
The gem is included in the Gemfile, but is not mentioned in the text.

gem ‘activemodel-serializers-xml’

151133TYPO

In the first paragraph, third sentence, there is a missing word “in” after the word “residing”. It should say, “… where the cart ID is internal state data residing in a cookie.”.

16ERROR

Not sure if this is your issue or mine. I’ve followed the installation instructions to install rails. I decided to try and follow your guide exactly so was using all the tool versions you specified aside from Ruby itself, which I previously updated to 2.4.2p198.

I installed Rails 5.1.3 and then created your demo app. When running “bin/rails about” I noticed that somewhere along the line Rails got updated to 5.1.4 so I went back to p.16 and followed your instructions.

However, putting the rails version between underscores doesn’t work as you describe:

Shareefs-MacBook-Pro:demo sjalloq$ rails 5.1.3 —version
Rails 5.1.4

Shareefs-MacBook-Pro:Rails sjalloq$ rails 5.1.3 new demo
blah blah
Shareefs-MacBook-Pro:Rails sjalloq$ cd demo/
Shareefs-MacBook-Pro:demo sjalloq$ bin/rails about
About your application’s environment
Rails version 5.1.4
Ruby version 2.4.2-p198 (x86_64-darwin16)
RubyGems version 2.6.13
Rack version 2.0.3
JavaScript Runtime Node.js (V8)
Middleware Rack::Sendfile, ActionDispatch::Static, ActionDispatch::Executor, ActiveSupport::Cache::Strategy::LocalCache::Middleware, Rack::Runtime, Rack::MethodOverride, ActionDispatch::RequestId, ActionDispatch::RemoteIp, Sprockets::Rails::QuietAssets, Rails::Rack::Logger, ActionDispatch::ShowExceptions, WebConsole::Middleware, ActionDispatch::DebugExceptions, ActionDispatch::Reloader, ActionDispatch::Callbacks, ActiveRecord::Migration::CheckPending, ActionDispatch::Cookies, ActionDispatch::Session::CookieStore, ActionDispatch::Flash, Rack::Head, Rack::ConditionalGet, Rack::ETag
Application root /Users/sjalloq/Rails/demo
Environment development
Database adapter sqlite3
Database schema version 0
Shareefs-MacBook-Pro:demo sjalloq$

279SUGGEST

metodo de pago
in line 51 does not use an escaped character for the accent in metodo

281SUGGEST

The screenshot contains the spanish text and not the english one.

33ERROR

Download location for nodejs is here: web page nodejs.org/en/download/
I couldn’t find the LTS version in the link in the book.

35SUGGEST

The commands you enter to see the version numbers doesn’t include checking for the version of yarn and chromedriver. should also have:

> yarn —version
> chromedriver -v

NB: The screenshot shows this already so that doesn’t have to be updated.

`72SUGGEST

Page 72, states that you’ll need to substitute the caret for the backslash at the end of the line and a backslash for the forward slash, but forgets to mention that you also need to add ’ruby’at the front of the command.

78SUGGEST

Page 78, when you try run ruby bin\\rails test it says you need to perform a migration: ruby bin\\rails db:migrate RAILS_ENV=test (after this it runs fine)

214SUGGEST

For Cloud9 IDE:

Install chromedriver as follows:
sudo apt-get install chromium-chromedriver

Update /depot/test/application_system_test_case.rb from:
driven_by :selenium
to:
driven_by :selenium_chrome_headless

Then system test may be run with the command:
rails test:system

259242ERROR

In the sketch on the top there is a box “Controller” with a function “login” that is never implemented.

254237SUGGEST

In the last paragraph you suggest using “legend” and “fieldset” tags, but they are not showing up in the code example that follows.

229212TYPO

In orders_controller.rb, the case statements for the pay_type should be changed from “Credit Card” to “Credit card”, lowercase ‘c’ on ‘card’. Same with “Purchase Order”, should be lowercase ‘order’.
This was not caught in the automated testing because the systems test is limited to choosing the ‘Check’ pay type.

217TYPO

(Note: I am using an online reader, so the page# given is probably not correct — it is dynamic based on font size, etc.)

This is in section “Iteration F1: Moving the Cart”

Current text: "Note that we’ve given the

element that wraps the CSS class carts"

Fix: "

" should be "

" to be consistent with the referenced code.

218TYPO

(Note: I am using an online reader, so the given page number is probably incorrect.)

Section: “Iteration F1: Moving the Cart”
Subsection: “Partial Templates”
Location: at the very end

The screenshot displayed here is slightly ahead of the text. In particular the section in the picture labeled “Your Pragmatic Catalog” actually replicates the Cart at this point. The following section “Changing the Flow” corrects this.

184ERROR

Why set “belongs_to :product, optional: true”? Each lineItem must have a product. I think it should be “belongs_to :cart, optional: true”?

The correct version is:

rails51/depot_o/app/models/line_item.rb

class LineItem < ApplicationRecord
belongs_to :order, optional: true
belongs_to :cart, optional: true
belongs_to :product

228ERROR

The expiration date is splitting on `//` and not on `/\\/`

36TYPO

as you would be should you be

278ERROR

The third bullet under ‘Playtime’ refers to Order::PAYMENT_TYPES, which doesn’t exist. In fact, the payment types were translated in an earlier part of the chapter (p. 267).

I suspect that this may be a holdover from an older edition of the book.

179TYPO

There is an error explaining the arguments of the following code: “form_with(model: @order, local: true)”

quoting the text:
“The first argument, module: @order tells the helper”

it should be “The first argument, model: @order tells the helper”

106TYPO

Dead link for zenspider quick ref. New link is :-
zenspider.com/ruby/quickref.html
and NOT
zenspider.com/Languages/Ruby/QuickRef.html

16SUGGEST

I also encountered the situation where I installed the Rails 5.1.3 gem (on Ruby 2.4.1), but running ‘rails new demo’ automatically installed 5.1.6, the latest version to date. I discovered that I had to edit my Gemfile to revert back to Rails 5.1.3:

gem ‘rails’, ‘5.1.3’ # with no ‘~>’

Then ‘bundle install’, and then after the list of dependency errors, run ‘bundle update’ as it suggests. This reverts Rails back to 5.1.3.

Might save others trouble if you could include a short explanation at this point on how to force Rails 5.1.3 for future readers, and what the ‘~>’ in the Gemfile actually means.

I posted full answer on SO, for reference (google “Why does Rails new install rails 5.1.6?”).

Otherwise, great book! I’m learning a lot, thanks.

293276ERROR

The language-button on the top of the webpage doesn’t work correctly because there was an expression missing in my config/routs.rb.
I don’t know if this is a personal problem (only on my machine) or a general problem.
The missing expression was ‘, via: :all’ after ‘root ’store#index’, as: ‘store_index’, ’.​
I don’t get where in the book I should change the line to that.

184ERROR

At the end of the page, the LineItem model is modified as follows:

belongs_to :order, optional: true
belongs_to :product, optional: true
belongs_to :cart

However, a line item is always associated with a product, while on the other hand a line item is not always in a cart (i.e. when a user checks out each item in the user’s cart will get cart_id set to nil before the cart is deleted). So it seems like a more correct configuration would be

belongs_to :order, optional: true
belongs_to :product
belongs_to :cart, optional: true

246ERROR

On p. 246, we whitelist a bunch of actions after having added the authorize callback to all actions. However, the whitelisted actions are incomplete. It is necessary to also whitelist the following to actions:

CartsController :show (otherwise impossible for non-admin to view cart)

LineItemsController :destroy (otherwise impossible for non-admin to remove items from cart)

344TYPO

“thows” should be “throws”

74ERROR

The migration fails because the generated code has : title instead of :title in the products.rb code and also in one other location. Removing the space inbetween “:” and “title” in both cases solves the problem.

74ERROR

Further to my previous post, the : title problem occurs all over the app…

syntax error, unexpected ‘:’ …ut_buffer.append=( form.label : title );output_buffer.safe_... ... ^ /Users/xxx/depot/app/views/products/_form.html.erb:16: syntax error, unexpected ':' ...ffer.append=( form.text_field : title );output_buffer.safe_… … ^

Extracted source (around line #15):
13
14
15
16
17
18

<%= form.label : title %>
<%= form.text_field : title %>

73SUGGEST

Further to my two prior posts on this issue regarding the : title problem (p73 not -p4 as reported), the issue is caused by an unfortunate line-wrap in the command:

bin/rails generate scaffold Product \\title:string description:text image_url:string price:decimal

Which appears in the book as:

bin/rails generate scaffold Product \\
title:string description:text image_url:string price:decimal

There is a space before the “\\” but there must not be a space after the “\\”

Life is fun, is it not?

73SUGGEST

It would be useful to be able to edit one’s own posts - typos are easy to make…

The error reported on p74 was on p73. The reference to p4 was just another typo…

179TYPO

The first argument, module: @order tells the helper which instance variable to use when naming fields and sending the form data back to the controller (the second argument tells Rails not to post this form via Ajax, which became the default in Rails 5.1).

should be

The first argument, model: @order tells the helper which instance variable to use when naming fields and sending the form data back to the controller (the second argument tells Rails not to post this form via Ajax, which became the default in Rails 5.1).

205ERROR

Iteration H1.
After successfully deploying webpacker which was confirmed by being able to display “Hello React” as per page 200, i am unable to display the pay-type dropdown menu after deploying all the code up to and including p205.
The error message in the log file states that Webpacker compilation failed due to:
ERROR in ./app/javascript/packs/pay_type.jsx
Module not found: Error: Can’t resolve ‘PayTypeSelector’ in ‘../depot/app/javascript/packs’
Have others experienced this error

180180ERROR

The following code can not set id in select field

<%= form.select :pay_type, Order.pay_types.keys, id: :order_pay_type, prompt: ‘Select a payment method’ %>

It is necessary to modify the code as follows.

<%= form.select :pay_type, Order.pay_types.keys, {prompt: ‘Select a payment method’}, id: :order_pay_type %>

146SUGGEST

Implementation of ```cart#total_price` can also be written shorter:

```
def total_price
line_items.sum(&:total_price)
end
```

214TYPO

Second to last paragraph says “adding that item to the card.” I believe this is meant to say “cart”.

189TYPO

A number of different feed formats exit

should probably read…

A number of different feed formats exist

179TYPO

In the fifth line, there’s a html/ruby code:

“<%= form_with(model: @order, local: true) do |form| %>”

While, in the 13th line, there’s a reference to that line, but instead of “module” it should be “model”:

“The first argument, module: @order tells the helper which instance variable to”

It’s just a small typo error.

Have a nice day. Regards.

190ERROR

The who_bought.atom.builder file seems to have an error. When typed as written on line 3 (feed.updated @latest_order.try{:updated_at}, the site, and feed readers throw an error ( undefined method “xmlschema” for :updated_at:Symbol ).
When I change the line to read .try{updated_at} (no colon), the feed loads perfectly.

3613ERROR

At the end of the page, we are told install ChromeDriver for MacOS X using the following command:

brew install chromedriver

However, the following error is given when running this command:

Error: No available formula with the name “chromedriver”
It was migrated from homebrew/core to homebrew/cask.
You can access it again by running:
brew tap homebrew/cask
And then you can install it by running:
brew cask install chromedriver

If you follow the instructions given, it works as expected:

>> brew tap homebrew/cask
==> Tapping homebrew/cask
Cloning into ‘/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask’…
remote: Enumerating objects: 4096, done.
remote: Counting objects: 100% (4096/4096), done.
remote: Compressing objects: 100% (4086/4086), done.
remote: Total 4096 (delta 23), reused 678 (delta 8), pack-reused 0
Receiving objects: 100% (4096/4096), 1.31 MiB | 1.16 MiB/s, done.
Resolving deltas: 100% (23/23), done.
Tapped 1 command and 3989 casks (4,102 files, 4.2MB).

>> brew cask install chromedriver
> Satisfying dependencies > Downloading chromedriver.storage.googleapis.com/73.0.3683.20/chromedriver_mac64.zip

######################################################################## 100.0%
> Verifying SHA-256 checksum for Cask 'chromedriver'. > Installing Cask chromedriver
==> Linking Binary ‘chromedriver’ to ‘/usr/local/bin/chromedriver’.

47ERROR

A new version (1.4.0) of the sqlite3 gem was released in February 2019. This version does not seem to play nicely with the app that we’re creating. I get the following error:

Specified ‘sqlite3’ for database adapter, but the gem is not loaded. Add `gem ‘sqlite3’` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).

Forcing the sqlite3 gem version to the latest 1.3 version (that is, 1.3.13) in the app’s gemfile, then running bundle install and bundle update, sorts out this issue.

197179TYPO

In first paragraph under code block:
module: order should be: model: order

Categories: