By Developers, For Developers

Historical errata for Agile Web Development with Rails 5

`

—Askar Karasaev

PDF PgPaper PgTypeDescriptionFixed onComments
11TYPO

Chapter: Installing on Mac OS X
When it asks you to install the XCode CommandLine Tools, say yes.

Must be: Xcode

2016-04-07
80SUGGEST

app/assets/stylesheets/products.css.scss
should be
app/assets/stylesheets/products.scss
the name of file actually has been generated

2016-04-07
75OK

On Seeing the List of Products section:

`… if you chose something besides SQLite 3).`

I think that should be:

`… if you choose something besides SQLite 3).`

2016-04-11chose (past tense) is correct here.
51TYPO

Keys in a particular hash must be unique—should you have
two entries for :drum, the last one with win.

will win??

2016-04-08
94OK

Lots of code missing from product_test.rb

Hard to follow explanation in book, since code is only in the downloaded source code.

2016-04-11
79ERROR

When attempting to download initial image files at <https:{//}media.pragprog.com/titles/rails5/code/rails50/depot_a/app/assets/images/> I get a “Forbidden” error: “You don’t have permission to access /titles/rails5/code/rails50/depot_a/app/assets/images/ on this server.”

2016-04-12Until this is fixed, you can download those images from http://intertwingly.net/tmp/rails50_images/
94TYPO

I agree with Tom Chappell: something is missing on page 94. Near the bottom, a paragraph states “Next, we’ll test that we’re validating that the image URL ends with one of .gif, .jpg, or .png”, followed by a method definition for “new_product” allowing a URL to be passed in, as I might have expected.

However, the very next paragraph says “Here we’ve mixed things up a bit. Rather than write the nine separate tests, we’ve used a couple of loops…”.

The next paragraph says “You’ll notice that we’ve also added an extra parameter to our assert method calls.”

The code changes being referred to seem to be completely missing.

2016-04-11Thanks!
9479TYPO

Accessing URL media.pragprog.com/titles/rails5/code/rails50/depot_a/app/assets/images/
gives error:

Forbidden

You don’t have permission to access /titles/rails5/code/rails50/depot_a/app/assets/images/ on this server.

2016-04-12Until this is fixed, you can download those images from http://intertwingly.net/tmp/rails50_images/
9782OK

In the `rails50/depot_a/app/views/products/index.html.erb`, I think you forgot to include

`

<%= product.price %>

2016-04-11Price is added in iteration C2
124ERROR

The line_items_controller_test.rb shown on page 124 appears out-of-order: it includes assert_select methods looking for content that isn’t added to the shopping cart until page 125; but the text suggests the test will pass (it doesn’t). Also, the text following it talks about the ‘assigns’ statement, but there isn’t one in that test. Finally, there is no mention of the purpose of the ‘follow_redirect!’ line that is added.

2016-04-13The code is correct, the paragraph before and after the code are incorrect. The test should pass after the change: http://intertwingly.net/projects/AWDwR4/checkdepot-224-500beta3/section-9.4.html \n \nHere's what will replace the paragraph that preceded that code: \n \n <<< For starters, we only need to pass a product ID on the call to \n post. Next we have to deal with the fact that We are no longer \n redirecting to the line items page, we are instead redirecting to the \n cart, where the cart id is internal state data residing a cookie. As this \n is an integration test, instead of focusing on how the code is \n implemented, we should instead be focusing on what the user \n sees, which, after they follow the redirect, will be a page with a heading \n identifying that they are looking at a cart, and with a list item \n corresponding to the product they added.>>> \n \nThe paragraph afterwards will be deleted. \n \n
32ERROR

“…is to create a new template in the directory app/views/say…”

The template is already generated. So it’s not really a new template.

2016-04-13
383SUGGEST

Chapter 21, page 378…

Very, very, nit picky. But might be helpful for newbies.

If the my_action.html.erb template contained this:

<%= @msg %>


the browser would see the following HTML:

Hello, World!

Your HTML shows “Hello World!” but nowhere did you explicitly set @msg to that string.

2016-05-04
5SUGGEST

On page 5 you might want to specify to run the command rm -rf * not only because you will go through the steps to create a project, but also because the Cloud9 default Rails version is 4.2.5

Therefore we need to make sure to install the version 5.0.0 by running gem install rails –version=5.0.0.beta3 –no-ri –no-rdoc and then to verify the version by running rails -v

2016-05-04
56ERROR

Sample code is “class Order < ApplicationRecord” but text says:

“This Order class is defined to be a subclass of the class Base within the ActiveRecord module.”

This should be fixed to:

“This Order class is defined to be a subclass of the class ApplicationRecord within the ActiveRecord module.”

2016-05-07
5TYPO

Section: Hello Rails!, Box: Making Development Easier, epub page 5 of 7 in section

The last sentence has the wording “for production deploymenti See”, the “i” needs removed from “deployment”

2016-05-21
3TYPO

Section: Linking pages together

On the last page the last paragraph begins “So far, we just done things…”. This should be changed to “So far, we have just done things…”.

2016-05-21
epub TYPO

Section: When things go wrong. p. 2 of 4 in section. The sentence “We’ll return to this later explain this in detail, …” should be “We’ll return to this later to explain this in detail…”.

2016-05-21
345SUGGEST

No mention seems to be made about dealing with the SECRET_KEY_BASE (see config/secret.yml) when moving the code to production. By default an environment variable needs to be set on the server for the app to work (I’m on Debian). It might be worth indicating the steps to resolve this or a few readers might spent time wondering why their app doesn’t want to start…

2016-06-08
14TYPO

from forums 398 topics 14260… since i can’t use links… would be nice to be able to link to forum topics… also being able to refer to content else where is useful to be complete… this just seems kinda overkill since i would hope that someone would at least review an errata post… also… i mean… this is code about html… how can i be complete if i am talking about a url in this errata…

sorry, noticed this method of reporting after i posted that. also, 2.3.1 and rails 5.0.0.rc1 are current for those, and relevant to that post. and at the time i think i was reading b2, but i just went back and its still that way in b3.

in the book it states:

$ brew install rbenv ruby-build $ echo ‘eval “$(rbenv init -)”’ » /.bash_profile $ source/.bash_profile $ rbenv install 2.3.0 $ rbenv global 2.3.0

anyone who in the past that had used rbenv with out brew might want to be cautioned to uninstall the old version first otherwise you can end up with odd things happening like in this bug report:

see github.com/rbenv/ruby-build/issues/861

also, rvm also works on macos… so, in a way i feel that it should also be mentioned and that they can reffer to the linux notes about that because that for the most part is the same.

hum… on 2nd reading… the rvm part is not part of the linux install notes but, a new topic? and not clearly delineated…

also, in the rvm section it states:

“The use keyword is optional, so you can abbreviate this to rvm 2.0.0. You can also choose to make it the default Ruby interpreter for new Terminal sessions with the following command: $ rvm –default 2.0.0”

those should be 2.3.0 instead yes?

lastly, the reader might want be cautioned that using rbenv and rvm on the same machine can cause issues, and the uninitiated might want to install one or the other until they are confidant that they can work out the potential conflicts.

2016-05-22
36ERROR

as of ruby 2.3.1, rails 5.0.0.rc1, safari 9.1.1 the error for /say/h3llo does not by default show the routes and request unless you click on Application Trace => the first time i visited the url in error <=.

from that point on though, it did the same things as shown. even when i switched to chrome.

2016-08-16I haven't been able to reproduce this just yet.
53SUGGEST

the end for the while block is on the next page. while, in most cases i would not care. it would seen that in this case it might be useful to see the entire block on the same page since your pointing out a while ends with an end…

2016-08-10Pagination is done later in the production cycle
34TYPO

by an misfiring autocorrect

should be

by a misfiring autocorrect

2016-05-24
59SUGGEST

“class CreateProducts < ActiveRecord::Migration[5.0]”

It might be worth mentioning what the “[5.0]” bit does. Even though I’m an experienced Ruby programmer, I did a big double take at it. After thinking about it, I worked out what it was, but a beginner might not.

2016-06-07
85TYPO

“…link includes the parameter method: :delete”

That’s really “method: :delete”. The space is significant - without it, you get a syntax error.

2016-06-08Added to the "Introduction to Ruby" chapter
90SUGGEST

I was typing in the regular expression : %r{\\.(gif|jpg|png)\\Z}i,

and it got confusing from the pdf. The forward slashes looked very similar to the pipe symbols. I should have known better but in the PDF both symbols looked the same so I used forward slashes throughout. Only when my tests failed later in the chapter did I catch this. Perhaps it can be explicitly pointed out that two different characters are being used here.

2016-06-08
75SUGGEST

The title on the products page (the figure) in the newly created application should display

Products

instead of

Listing products

2016-06-06
107TYPO

“The real magic, however, takes place on line 25. When we invoke yield, ”

yield method is actually on line 28:
25

-

-

- <%= yield %>
-

-

-

35

2016-08-17Seems to be a production tool change problem. I've notified the appropriate people and they are investigating.
82SUGGEST

Shouldn’t the following line (line 1) produced from scaffolding, be kept when making the css changes?

<%= notice %>

2016-06-07
120SUGGEST

The code provided at the top of the page: rails50/depot_f/app/controllers/concerns/current_cart.rb could use some more context.

First I wasn’t sure if this code was suppose be generated by scaffolding (and I mess something up because it wasn’t in my project).
Second this first time we have been introduced to Concerns… how do they fit into Rails? Why is it separate from the normal Controller code?

2016-06-08
126ERROR

when asked to rerun the tests, this will fail:
assert_select ‘h2’ , ‘Your Pragmatic Cart’

Until the code is applied on page 127 (rails50/depot_f/app/views/carts/show.html.erb)

Maybe tell reader to run test after the updating the view?

2016-06-08
93OK

Shouldn’t the numbers displayed after running the test for a newly created application be different?

Initial output after adding the first tests (product attributes must not be empty) is:

8 runs, 17 assertions , 0 failures, 0 errors, 0 skips

2016-06-08I'm getting 5 and 23: see http://intertwingly.net/projects/AWDwR4/checkdepot-50/section-7.2.html
102SUGGEST

with Rails 5.0.0.rc1 the config/routes.rb file does contain any commented out root line.

It only contains the following when created:

Rails.application.routes.draw do
# For details on the DSL …
end

2016-06-08
107SUGGEST

With Rails 5.0.0.rc1 the turbolinks is:

‘data-turbolinks-track’ => ‘reload’

instead of:

“data-turbolinks-track”=> true

2016-06-08
114SUGGEST

rails dev:cache

Since this is a new feature, should it be worth adding a box maybe with the explanation of how it works and how it can be switched on/off ?

2016-06-23Covered by Iteration C5: Caching of Partial Results. Added a sentence to indicate that this command toggles caching on and off.
120OK

Should the def set_cart have the same indentation as the private keyword above it, according to the ruby style guide?

2016-06-23This is one of the few places where the Rails team deviates from the ruby style guide.
124SUGGEST

After adding the before_destroy callback, the test for the product controller fails on the test_should_destroy_product.

This is because the fixture for the product(:one) has also is included in the line_items fixture.

To get over it and make the test pass again we should either use the product(:ruby) in the products_controller_test setup or remove the fixture that includes the product(:one) from the line_items fixture.

2016-06-23
124ERROR

124 contains a line below.

“If the hook method returns false, the row will not be destroyed”

However, by default, Rails 5 stops callback chain with “throw :abort”, not “return false”.

2016-06-23
136SUGGEST

Wouldn’t it be better (ruby style guidelines) if the parameters cart_id, product_id and quantity are aligned?

2016-06-23
117ERROR

In the listing for ‘rails50/depot_e/app/views/store/index.html.erb’, in the second nested cache block, the variable should be ‘product’ and not ‘@product’. It refers to the parameter |product| of the block.

2016-06-23
140TYPO

At the end of the paragraph about log files (end of page), it abruptly shows the line “the following screen shot shows a better way.”, and there’s a screenshot related to the preceding paragraph. The line is truncated and the screenshot is confusing because one expects something related to the logfiles.

2016-06-23
146ERROR

There are a number of areas where you don’t cover updates to the tests in the text. They are done in downloaded source code, but not in the text. For example, in section E3, you update the cart display and change the title of from “Your Pragmatic Cart” to “Your Cart”. That requires an update to the “should create line_item” test in the line_item controller test file which is done in the source code, but not covered in the text. Also, the listing of line items in the display is changed from

  • tags to

    tags. Again, that requires a change in the same test which is done in the source code, but not covered in the text.

    Same is true for the post #80417. The line_items fixture file is changed in the source code so that fixture “one” references product “two” to resolve the failed test. Also, a test is added in the source code for attempts to delete a product with a line_item still associated. These are not covered in the text.

    ...) were replaced with one (render(...)).

    <% else %>

    <% end %>

    2016-06-23
    152ERROR

    Inside of the partial for `rails50/depot_j/app/views/carts/_cart.html.erb`, you have the <%= notice %>, but the description of the partial says explicitly not to output the notice:

    This is basically our carts/show.html.erb template but using cart instead of @cart, and without the notice.

    The `notice` is output in the next template, `rails50/depot_k/app/views/carts/show.html.erb` as well, which would cause a “double notice”.

    2016-06-23
    122ERROR

    “… and have that module extend ActiveSupport::Concern”

    There is no mention of Concern in the code. And looking at the downloaded depot_f code, it doesn’t contain the word Concern.

    2016-06-23
    122ERROR

    Text contains the setence “Note that we place the set_cart() method in a CurrentCart module and have that module extend ActiveSupport::Concern.”

    However, there is no “extend ActiveSupport::Concern” anywhere in the listed current_cart.rb. Is it supposed to be in there at this point? If that’s done later in the chapter, the sentence above isn’t all that helpful as written…

    2016-06-23
    135SUGGEST

    After adding

  • <%= item.quantity %> × <%= item.product.title %>

  • the test for creating a line item in the line_items_controller_test.rb fails.

    A way to fix this is to have the above line changed (could not find a way to test with ×) to:

  • <%= item.quantity %> x <%= item.product.title %>

  • and then test for:

    assert_select ‘li’, ‘1 x Programming Ruby 1.9’

    2016-06-23
    142OK

    Since we are only interested in the line_items_controller_test output wouldn’t it be easier to run only this test before looking at the log file (or having tail -f running) instead of running all the controller tests ?

    rails test test/controllers/line_items_controller_test.rb

    2016-06-23I'd rather run all of the controller tests to verify that there are no other problems.
    156SUGGEST

    “Sure enough, if we try to display the products index…”

    It might be worthwhile explaining how to display the products index. Something like:

    Sure enough, if we try to display the products index (by pointing our browser to ttp://localhost:3000/products)…

    2016-06-23
    118ERROR

    Cacheing partial results is not working. Every time I tried to edit the template and refresh the page i could see the change immediately. I have even tried to substitute the @product variable with product.. still no luck.

    2016-08-10It is working, but Rails has gotten even smarter about cache invalidation. I've updated the text to indicate another way to verify that the cache is working.
    50ERROR

    Installing on a Virtual Machine doesn’t on Fedora 24, Ruby 2.3.1. The error:
    The provider ‘libvirt’ could not be found
    Does this mean I have to have a Ubuntu 16 pc?

    2016-08-10
    50ERROR

    Installing on a Virtual Machine doesn’t on Fedora 24, Ruby 2.3.1. The error:
    The provider ‘libvirt’ could not be found
    I use vagrant and I know it works:-)

    Okay, after some head scratching:
    change the forwarded port to an available port
    vagrant up —provider virtualbox

    Is this something you could address in an upcoming update?

    2016-08-10
    36TYPO

    At the top of the page: ‘localhost’ is misspelled. Currently reads ‘locahost’

    2016-08-10
    20ERROR

    The link for the DB2 driver points to a very old driver. The current driver for all IBM Data Servers (including DB2, but also works with Informix) is “ibm_db” rather than “db2”. So change the URL for Rubygems accordingly (replace the “db2” with “ibm_db”.

    2016-08-10
    151134OK

    it looks like the add_product method defined here does not work properly. The issue I found is that because the migration to add the new quantity field did not set a default value, those values are null in the database. When we enter into the add_product method, we attempt to increment a null value which caused errors. I was able to fix this by editing the code in that helper function and also by setting a default value on the migration.

    2016-08-10But the migration does set a default value: \n \nadd_column :line_items, :quantity, :integer, default: 1
    187170ERROR

    the actioncable channel the book says needs to go in app/channels/application_cable/products_channel.rb, but it really needs to be in app/channels/products_channel.rb (at least in rails 5.0.0)

    If you put it where the book says to, the following is logged:

    Finished “/cable/” [WebSocket] for 127.0.0.1 at 2016-07-05 15:17:30 –0500
    Started GET “/cable” for 127.0.0.1 at 2016-07-05 15:17:31 –0500
    Started GET “/cable/” [WebSocket] for 127.0.0.1 at 2016-07-05 15:17:31 –0500
    Successfully upgraded to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: Upgrade, HTTP_UPGRADE: websocket)
    Subscription class not found: “ProductsChannel”

    2016-08-10
    57TYPO

    two typos: missing apostrophe in “lets” and repeated word “other” in phrase “now lets break the other other thing”

    2016-08-10
    117ERROR

    What is the point of introducing the self.latest method here?
    It is not used with the caching strategy.

    2016-08-10
    0 TYPO

    in ‘code’ archive and following, missing ‘end’ around line 60 in test/ products_controller_test

    2016-08-09
    4322ERROR

    With Windows, using the command “bin\\rails about” is not possible as the file “rails” is not an executable/batch. Instead using “ruby bin\\rails about” works in my case.

    2016-08-10
    168OK

    After I wrote hidden_div_if helper method, I encountered the exception (undefined method for nil:NilClass) when I accessed /products page because @cart is nil in products controller.

    2016-08-10Indeed. This is noted, and fixed, 5 pages later.
    205ERROR

    incorrect sentence: “Because we cleared out the orders table at the start of the test, we’ll simply verify that it now contains just our new order.” Instead of clearing out table, count was stored as start_order_count.

    2016-08-11
    232TYPO

    Despite what the text claims, default_url_options is not used in the code anywhere.

    2016-08-11
    198TYPO

    “The generate script created two email templates in app/views/order_mailer, one for
    each action in the ApplicationMailer class.”

    I believe this should be each action in the OrderMailer class.

    2016-08-11
    187SUGGEST

    It is better to use ApplicationCable::Channel instead of ActionCable::Channel::Base when defining ProductsChannel

    class ProductsChannel < ApplicationCable::Channel

    And how about using `rails g channel products` command?

    2016-08-11
    105TYPO

    the url shown in the image is out of sync with the text discussion around it.

    you tell the user to go to the root but the image is showing the url of the page before you modified the routes and made that no longer a valid url.

    2016-08-10
    192OK

    The result of bin/rails db:migrate is the following in the book.

    — add_column(:line_items, :order_id, :integer)

    But actual result is the following in Rails 5.0

    — add_reference(:line_items, :order, {:foreign_key=>true})

    2016-08-11That's not what I see: http://intertwingly.net/projects/AWDwR4/checkdepot-50/section-12.1.html#cmd3
    203SUGGEST

    How about using bin/rails db command instead of sqlite3?

    sqlite3 -line db/development.sqlite3 # (in the pdf)

    bin/rails db —mode line # (my suggestion)

    2016-08-11Unfortunately bin/rails dbconsole doesn't take a string with the command to be executed :-(. \n \nI'm leaving it as is for now.
    287ERROR

    The lib directory is listed as a standard application load path in contradiction of “A Place for Supporting Libraries” on page 283 which states this is no longer true and includes code for adding it.

    2016-08-16
    170TYPO

    This sentance “As we will only sending data over this channel, and not processing commands, this is safe to do” seems to be missing a “be”

    2016-08-10
    171TYPO

    The word another is duplicated in this sentence:

    “This function looks to see if there is an HTML element with an ID of main which is contained in another another element with a class of store.”

    2016-08-10
    283ERROR

    All of the documentation tasks referenced in “A Place for Documentation” have been removed.

    2016-08-16
    170ERROR

    The products_channel.rb file should be placed in the app/channels directory, not the app/channels/application_cable directory.

    2016-08-10
    170ERROR

    I think there is an error here : “The way to create a channel is by creating a file in the app/channels/application_cable directory:

    rails50/depot_n/app/channels/application_cable/products_channel.rb”

    It seems that products_channel should be placed in app/channels/ rather than app/channels/application_cable/
    Following the instructions from the book, I wasn’t receiving any message from ActionCable and had the following error in my logs: `Subscription class not found: “ProductsChannel”` (my rails version : 5.0.0)

    I hope this helps! Thank you for this book.

    2016-08-10
    211ERROR

    “As it stands now, the index view doesn’t display notice information” -> this is actually already the case

    2016-08-11
    208192ERROR

    The @product.to_xml in Playtime of Task G does not work in Rails 5.0.0.1,
    I think this is because XML serialization was removed from core.
    (github.com/rails/rails/pull/21161)

    To make @product.to_xml work, activemodel-serializers-xml seems to be needed.

    2016-08-16
    170ERROR

    Following along with the ActionCable example, I kept getting `Subscription class not found: “ProductsChannel”` from Puma.

    I’m running actioncable 5.0.0.1 and rails 5.0.0.1.

    I fixed the problem by moving the `products_channel.rb` file up one directory: from `app/channels/application_cable/products_channel.rb` to
    `app/channels/products_channel.rb`. I’m guessing the `app/channels` directory is where rails looks for *_channel.rb files.

    Incidentally, ProductsChannel can extend the ApplicationCable::Channel class defined in `app/channels/application_cable/channel.rb`. That might be the Right Thing, as the ApplicationCable::Channel class can be larded with stuff all your channels should be doing, at least until DHH adds channel concerns to the framework.

    I’m really enjoying the book as a way to refresh and update my rails knowledge. Thank you for updating this classic.

    2016-08-16
    263ERROR

    I ran into some trouble getting deployment to work. I think I’ve found at least some of the issues. The presentation of the Capfile on page 263 seems to be Capistrano-2-specific:
    ```
    load ‘deploy/assets’
    load ‘config/deploy’
    ```

    In Capistrano 3, the deploy line should be
    `require ‘capistrano/deploy’`

    And to get asset pipelining working, uncomment the line
    `require ‘capistrano/rails/assets’` lower in the generated Capfile.

    2016-08-30
    202OK

    rails50/depot_r/test/mailers/order_mailer_test.rb
    when I run this test, it failed. the reason is
    test/fixtures/line_items.yml should be
    two:
    product: ruby
    cart: two
    order: one
    we missed order: one in source code.

    2016-08-30This change was made in iteration G1.
    395TYPO

    “add_table() is reversible” -> should be create_table

    2016-08-30
    196OK

    In the book, ‘the default in development mode is :smtp .’
    But in rails 5.0.0.1, I can’t find config.action_mailer.delivery_method setting in config/environment/development.rb

    $ rails new depot
    $ cd depot
    $ bin/rails c
    irb(main):001:0> Depot::Application.config.action_mailer.delivery_method
    => nil
    irb(main):002:0>

    2016-08-30It is indeed there: http://media.pragprog.com/titles/rails5/code/rails50/depot_q/config/environments/development.rb (and remains there in 5.0.0.1). Look around line 42. And is documented in the published documentation: http://edgeguides.rubyonrails.org/action_mailer_basics.html#action-mailer-configuration-for-gmail
    405ERROR

    The text claims that, “then we will proceed to describing how you can do the same things on a remote machine.” The chapter does not however cover this topic.

    2016-09-02
    8161ERROR

    This line:
    So, count ||= 0 gives count the value 0 if count doesn’t already have a value.

    is true, but incomplete. A developer using ||= true to conditionally initialize a Boolean-valued variable has caused overriding problems for us before. It’s best to mention:

    (note: If count has value nil or false, it will now have value 0 as well)

    2016-09-02
    10TYPO

    foreword, not forward

    (note: this is in revision history, not sure if it will make it to the final print)

    2016-09-01
    17xviiTYPO

    Scrum, not Scrums

    2016-09-01
    18xviiiSUGGEST

    Last sentence doesn’t make sense when the although … part is removed:
    One last point about agility and Rails is that think how much fun coding will be!

    The word “that” doesn’t quite fit because what follows is not a statement that could be true or false.

    Probably better:

    One last point about agility and Rails: Although it’s probably unprofessional to mention this, think how much fun the coding will be!

    2016-09-01
    265SUGGEST

    I’d assume novice readers who may not know the dangers of rm -rf *, and could try to type it on a console in their home directory. One option: Clarify with scary comment, as in:

    rm -rf * # remove all files and folders!! — Do this online, NOT on your machine!!

    2016-09-01Made it clear that this command is only to be entered in the web browser window
    3514TYPO

    In two places, 2.0.0 is not updated to 2.3.1 yet:

    so you can abbreviate this to rvm 2.0.0 —> 2.3.1

    rvm —default 2.0.0 —> 2.3.1

    2016-09-01
    4019SUGGEST

    SQLite 3 too
    —>
    SQLite 3, too.
    or (reads better) —>
    SQLite 3 as well.

    2016-09-01
    212TYPO

    There is no mark which specifies modified lines in rails50/depot_r/app/views/users/_form.html.erb in the text.

    2017-02-26
    218OK

    In the line_items_controller test I believe that the suggested assert:

    “assert_select ​’li’​, ​”1 ​​\\u​​00D7 Programming Ruby”

    Should actually be:

    assert_select ‘#main li’, “1 \\u00D7 Programming Ruby 1.9”

    Otherwise it will find the #side li item Home

    It works as is. What this test is stating is that there is at least one list item that contains the specified string.
    139SUGGEST

    rails50/depot_f/app/controllers/concerns/current_cart.rb

    This file not created by Rails, needs manual creation but this isn’t specified.

    2017-03-07
    180OK

    I have just looked for the issues in version 4 and found that this fix in products controller works:


    before_action :set_product, only: [:show, :edit, :update, :destroy, :who_bought]

    Would be nice to have explanation and the fix in the book.

    regards

    Laura

    Not needed given that the first line of who_bought is: \n \n@product = Product.find(params[:id])
    202TYPO

    Once his does… should be he does

    2017-02-26
    207SUGGEST

    “We start with the controller. It defines the standard methods: index(), show(),
    new(), edit(), update(), and delete().”
    You did not mention create() that you amend next…
    For me it was cofusing.

    2017-02-26
    243SUGGEST

    In playtime of chapter 14, the text says ‘if the request.format is not Mime::HTML .’.
    But in Rails 5.0.0.1(actionpack-5.0.0.1), Mime::HTML is deprecated. I think it is better to use Mime[:html] instead of Mime::HTML

    $ bin/rails c
    Loading development environment (Rails 5.0.0.1)
    irb(main):001:0> Mime::HTML
    DEPRECATION WARNING: Accessing mime types via constants is deprecated. Please change `Mime::HTML` to `Mime[:html]`. (called from irb_binding at (irb):1)
    => #<Mime::Type:0x00560ec81248f0 synonyms=["application/xhtml+xml"], symbol=:html, string="text/html", hash=–4244176682379425993>

    2017-02-28
    251TYPO

    Modified mark is missing in the following line in rails50/depot_t/app/views/store/index.html.erb

    <%= t(‘.title_html’) %>

    2017-02-28
    253ERROR

    To display order page in Spanish, new_order_path should be new_order_path(I18n.locale) in rails50/depot_t/app/views/carts/_cart.html.erb

    <%= button_to t(‘.checkout’), new_order_path(I18n.locale), method: :get %>

    2017-03-09
    261ERROR

    To display Spanish message after order was placed, orders_controller should redirect to store_index_url(I18n.locale) in rails50/depot_u/app/controllers/orders_controller.rb

    format.html { redirect_to store_index_url(I18n.locale), notice:

    2017-03-09
    262TYPO

    It seems to me that the screenshot is not correct because button label (add to cart) and side bar’s link labels (Home, Questions,…) are English, only cheery message is Spanish.

    2017-03-09
    262OK

    In iteration J4, I encountered ActionController::RoutingError when I changed language selection.

    ActionController::RoutingError (No route matches [POST] “/store/index”):

    The get method parameter should be passed to form_for method in rails50/depot_u/app/views/layouts/application.html.erb

    <%= form_tag store_index_path, method: :get, class: ‘locale’ do %>

    I can't reproduce
    252OK

    After passenger installed, before accessing depot appliction from browser, I think it is better to run ‘rails assets::precompile’ because default environment is production.

    I tested it again, and it worked without this addition.
    192DEFER

    I’d like to know how to test functionality implemented with ActionCable.

    Unfortunately, Rails doesn't yet have an answer for this: See https://github.com/rails/rails/pull/23211 for progress.
    320SUGGEST

    Order in depot application doesn’t have the amount attribute, so Order.average(:amount) doesn’t work.

    It may be straight forward because of the result is BigDecimal, but how about using Product and the price attribute?

    Product.average(:price)
    Product.maximum(:price)
    …(etc)

    2017-03-10
    329SUGGEST

    In rails 5.0.0.1, returning false in Active Model callbacks occurs the following deprecation warning message.

    DEPRECATION WARNING: Returning `false` in Active Record and Active Model callbacks will not implicitly halt a callback chain in Rails 5.1. To explicitly halt the callback chain, please use `throw :abort` instead.

    How about adding this information as an annotation?

    2017-03-10
    330ERROR

    The file name which defines Encrypter class should be encrypter.rb instead of encrypt.rb.

    In pdf page 330 Encrypter class is defined in encrypt.rb file. But in pdf page 331, ‘encrypter’ is required to use Encrypter class in Order class. It occurs the following LoadError because the file name is encrypt.rb.

    LoadError (cannot load such file — encrypter)

    And I think that requre ‘encrypter’ can be omitted if encrypter.rb is placed in app/model directory.

    2017-02-28
    332TYPO

    The text says “To do that, we’ll add it to the ApplicationRecord class:”, but `it` is added in ActiveRecord::Base class in the following script.

    2017-03-07
    332ERROR

    I downloaded rails50/e1/ar/encrypt.rb and placed it in depot directory and run encrypt.rb and I encountered Load Error (can’t load ‘connect’)
    I think encrypt.rb doesn’t work in Rails 5.0.0.1.

    To fix this error, I modified encrypt.rb.

    —- encrypt.rb 2016-09-19 13:30:03.301814748 +0000
    + fixed_encryped.rb 2016-09-19 13:35:11.047304290 +0000
    @@ –9,3 +9,2 @@
    $: << File.dirname(FILE)
    -require “connect”

    @@ –13,3 +12,6 @@
    require “active_record”
    +require ‘yaml’

    +config = YAML.load_file(‘config/database.yml’)
    +ActiveRecord::Base.establish_connection(config[‘development’])
    ActiveRecord::Schema.define do
    @@ –29,3 +31,4 @@

    -class ActiveRecord::Base
    +class ApplicationRecord < ActiveRecord::Base
    + self.abstract_class = true
    def self.encrypt(*attr_names)
    @@ –67,3 +70,3 @@

    -class Order < ActiveRecord::Base
    +class Order < ApplicationRecord
    encrypt(:name, :email)

    2017-03-10
    73SUGGEST

    There is an extra line in the output generated by the scaffold generator that is not included in the book, in the jbuilder section:

    create app/views/products/_product.json.jbuilder

    that should be below:

    create app/views/products/show.json.jbuilder

    and above:

    invoke assets

    2017-02-19
    109TYPO

    The text refers to specific line numbers for the code snippet above it, however the line numbers in the text do not match the line numbers on the code.

    2017-03-07
    1560TYPO

    Location 1560 reading in Kindle.

    line in book:

    violin: :string’

    There should not be a single quote after the symbol :string.

    2017-03-02
    199TYPO

    In the second line from the bottom, “order_test.rb” should be “order_mailer_test.rb”

    2017-02-26
    94OK

    When running only the model tests with bin/rails test:models
    the output should be:

    1 runs, 5 assertions, 0 failures, 0 errors, 0 skips

    and not:

    5 runs, 23 assertions, 0 failures, 0 errors, 0 skips

    That's not what I'm seeing: http://intertwingly.net/projects/AWDwR4/checkdepot-50/section-7.2.html#cmd5
    214ERROR

    With Rails 5.0.0.1, when updating tests, a test for AdminController would
    also need be modified.

    class AdminControllerTest < ActionDispatch::IntegrationTest
    test “should get index” do
    - get admin_index_url
    + get admin_url
    assert_response :success
    end

    2017-02-27
    216SUGGEST

    Just a minor detail, but it would be preferable, for perfection, to enclose
    “It’s <%= Time.now [snip] ”order“) %> ” in a HTML element(maybe simply in

    ?)
    for generating a well-formed HTML page.

    2017-02-27
    229ERROR

    There is a mention about default_url_options, but the method is not defined
    in the code presented above, and any further explanation is not found after
    this part neither.

    2017-03-07
    231OK

    While translation for layouts.application.title is provided, it is not used
    in the template cited on page 230 and 243. Perhaps the following is your
    original intention?:

    - <%= image_tag ‘logo.svg’, alt: ‘The Pragmatic Bookshelf’ %>
    + <%= image_tag ‘logo.svg’, alt: t(‘.title’) %>

    Actually, it is used thus: \n \n

    <%= t('.title_html') %>

    179TYPO

    At the end of application.scss “;” is missing for “display: none”

    br {
    - display: none
    + display: none;
    }
    }
    }

    2017-02-20
    74ERROR

    “And that’s it. Rake looks for all the migrations…”, Rake has not yet been introduced and referencing it is inconsistent with the new “bin/rails commands”. This will be confusing for newcomers.

    2017-02-19
    242225TYPO

    Hi, in the locale section the method “default_url_options” is mentioned but is nowhere used in the previous code sample. Possibly deleted?

    2017-03-07
    306292TYPO

    In the phrase “Every model class supports the method, which takes one or more primary
    key values”… it should probably read “Every model class supports the find method”.

    The description of the find method is given in the following lines.

    2017-02-28
    347333TYPO

    When describing the :url_based_filename option:
    “If true and :filename are not set, this option…” should probably read “If true and :filename IS not set, this option…”.

    2017-03-07
    102ERROR

    The route generated when running the controller generator should be:

    route get ‘store/index’

    instead of

    route get “store/index”

    single quotes instead of double quotes.

    2017-02-19
    106ERROR

    The actual application.html.erb generated is a little bit different from the one in the book (tag ordering, hash syntax, spacing). So the actual one is below:

    <p>Depot</p>

    <%= csrf_meta_tags %>

    <%= stylesheet_link_tag ‘application’, media: ‘all’, ‘data-turbolinks-track’: ‘reload’ %>
    <%= javascript_include_tag ‘application’, ‘data-turbolinks-track’: ‘reload’ %>

    2017-02-19
    39ERROR

    command TYPO page 39 : Text states surrounded by, sample shows only leading underscore…

    If it doesn’t, insert the version of Rails surrounded by underscores before the

    first parameter of any rails command. Here’s an example:

    $ rails _5.0.0.1 —version

    should have been been written:

    $ rails 5.0.0.1 —version

    2017-02-19
    45TYPO

    Missing word “we”

    We’ve already seen and modified a controller in Hello, Rails!, on page 24 and
    WE will be seeing and modifying a number of controllers

    2017-02-19
    79-80ERROR

    The text says that we should use the create!() method in seeds.rb but the example code uses create() (no bang) instead.

    2017-02-19
    369ERROR

    /\\Aimage/ should be used instead of /^image/.

    Using /^image/ in validates_format_of in Picture model creates ArgumentError. The detail message is the following:

    The provided regular expression is using multiline anchors (^ or $), which may present a security risk. Did you mean to use \\A and \\z, or forgot to add the :multiline => true option?

    2017-03-07
    370OK

    How about adding to explain adding routings to upload files into routes.rb?

    Nothing special is required for a route.
    398ERROR

    In the text, ‘only the first column name will be used when naming the index.’ when creating composite index. But it is not true in Rails 5.0.0.1.

    If `add_index :tab_name, [‘col1’, ‘col2’]` is executed, then the name of index is ‘index_tab_name_on_col1_and_col2’ .

    2017-03-07
    122OK

    The form, div section for the CSS file should be underneath the price section if we have the two closing brackets.

    The location is correct as is: it is meant to style form elements contained within the price_line.
    406SUGGEST

    I’m not sure, but it might not be easy to make ApplicationRecord works fine in the script in the text.
    So how about using ActiveRecord::Base instead of ApplicationRecord like as the following?

    class Order<ActiveRecord::Base
    end

    instead of

    class Order < ApplicationRecord
    end

    2017-03-02
    407SUGGEST

    Enumerable#group_by is provided by Ruby core. (at least 2.0.0 or later)
    If Rails(ActiveSupport) extend the functionality of Enumerable#group_by, it is better to explain the detail of the extension in the text.

    2017-03-02
    407SUGGEST

    File#path is provided by Ruby core (at least 2.0.0 or later).

    2017-03-02
    407TYPO

    I think that instance_variable_()names() is typo of instance_variable_names().

    2017-03-02
    138TYPO

    in the output of the log/test.log file the

    Unpermitted parameters: cart_id

    should be

    Unpermitted parameter: cart_id

    2017-02-20
    140SUGGEST

    the first two lines in the test are new:

    post line_items_url, params: { product_id: products(:ruby).id }
    @cart = Cart.find(session[:cart_id])

    2017-02-20
    147OK

    The code for the show.html.erb already exists, so shouldn’t it be displayed without the arrows that indicate new code?

    5 lines (
    229TYPO

    An arrow it’s missing on the code in this line:

    <%= t(‘.title_html’) %>

    Am I wrong or it should be like this?

    <%= t(‘.title_html’) %>

    2017-02-28
    159OK

    Wouldn’t it be better if the lines following the if and else in the _line_item.html.erb partial are indented two spaces?

    <% if line_item == @current_item %>

    I only do that when the whole element is enclosed by the if statement. In this case, only the open tag for the tr element varies.
    165SUGGEST

    The generator is called in previous cases with bin/rails, but here only rails is used.
    Shouldn’t it be better for consistency to be changed here to bin/rails ?

    2017-02-20
    174SUGGEST

    Should the new lines added in the new.html.erb, be highlighted as in previous code?

    The render for the partial already exists in the form.

    2017-02-20
    336TYPO

    def save_details
    unless params[:are_you_sure] == ‘Y’
    redirect_to(:back)
    else

    end #This should be purple
    end

    2017-03-09
    182SUGGEST

    Wouldn’t it be better if the ‘boxout’ about ‘Why Atom?’ comes after the finishing paragraph of iteration G1?

    2017-02-26
    93TYPO

    (top of page, first sentence): The assert line in this method is test.

    should maybe be: The assert line in this method is a test.

    2017-02-19
    93OK

    The product_test.rb file that gets downloaded has 2 faults.
    Line 62 says: product = Product.new(title: products(:ruby).title
    Line 62 should say: product = Product.new(title: products(:one).title

    Line 71 says: product = Product.new(title: products(:ruby).title
    and should say: product = Product.new(title: products(:two).title

    or the test will fail

    The ruby product was added to products.yml on the previous page.
    79SUGGEST

    When using the link to the images I suggest you use the Convenience bundles or you wont get the logo.svg needed further on.

    2017-02-20
    xxOK

    Just info: I bought this book 5 weeks ago in the Netherlands. The errata list is pretty useless if you only reference PDF page numbers!
    Regards Wim

    Best to report this to support@pragprog.com?
    280TYPO

    Under “What We Just Did”, the first bullet point states: “We generated both API and user guide documentation for Rails”. It doesn’t appear that api/guide generation is mentioned in this chapter. (Note: that bullet point also appears on the first page of the chapter in the header.)

    2017-02-28
    177158ERROR

    The Recent version of jquery-ui-rails (6.0.1) changed how to access the blind effect. It is now //= require jquery-ui/effects/effect-blind

    2017-02-20
    140TYPO

    In the carts_controller_test.rb code listing, I think the first two lines of the test method are new, even though they don’t have a triangle next to them. I’ve followed along the book pretty strictly, and my method did not have those lines in them The test failed without them.

    2017-02-20
    138ERROR

    I think the command rails test:controllers should likely be bin/rails test:controllers

    2017-02-20
    143SUGGEST

    In the Playtime section, the second bullet is worded confusingly. As I read it, I was unsure what the unit test was supposed to be testing. I actually thought that I was supposed to test that I could not add duplicate products to the database. It wasn’t until clicking through to the hints that I understood we were to test adding duplicate products to a cart. I think I would have understood more if the first sentence read, “Write unit tests that add both unique products and duplicate products to a cart.” It may also be helpful to indicate what assertions to test for: “Assert how many products should be in the cart in each instance.” Moreover, on the hints page, when I clicked the link to the “Author’s solution”, I received a 404 in response.

    2017-03-07
    154134OK

    In the code of test/controllers/line_items_controller_test.rb
    you say to add the line assert_select ‘li’, “1 \\u00D7 Programming Ruby 1.9”
    but i experience a mistake then i run the test. Because the element ‘li’ was taking from my app/views/layout/application.html.erb the side bar first element the Home.
    i change the code to assert_select ‘#main li’, ‘1 × Programming Ruby 1.9’
    and the test pass.

    I can't reproduce. Assert select tests to make sure that there is at least one match for the expression; scoping the test to #main shouldn't make it pass. The test should pass without that addition: http://intertwingly.net/projects/AWDwR4/checkdepot-50/section-10.1.html#cmd23
    158ERROR

    Hi, I’m following your book, and on the page specified with ‘bundle install’ I got version 6.0.1 of ‘jquery-ui-rails’. So the following line did not work: ‘//= require jquery-ui/effect-blind’. Soon I found the solution on the internet, replace with ‘//= require jquery-ui/effects/effect-blind’. That worked for me. If anyone has this problem I hope it helps.

    2017-02-20
    212ERROR

    rails test not pass. Because admin_controller_test tem url incorreta, onde foi gerado: get admin_index_url, mas o certo é get admin_url.

    2017-02-27
    212ERROR

    Rails test not pass. Because admin_controller_test has incorrect url, where it was generated: get admin_index_url, but the right one is get admin_url.

    2017-02-27
    180OK

    This section involves revealing the cart when an item is added to it.
    This line is added to the app/views/line_items/create.js.erb file:
    if ($(‘#cart tr’).length == 1) { $(‘#cart’).show(‘blind’, 1000); }

    However, the animations are not supported on table rows, so the blind effect doesn’t work.
    Some suggestions are to wrap the TR content in a div to allow the blind effect to work.

    This isn't doing animation on a table row. It is checking the number of rows and then doing the animation on the entire table.
    90OK

    updated Product model: rails50/depot_b/app/models/product.rb (page 90)
    class Product < ApplicationRecord
    validates :title, :description, :image_url, presence: true
    validates :price, numericality: {greater_than_or_equal_to: 0.01}


    1. validates :title, uniqueness: true
      validates :image_url, allow_blank: true, format: {
      with: %r{\\.(gif\\jpg\\png)\\Z}i, (incorrect use of backslash, source code from site uses a pipe!)
      message: ‘must be a URL for GIF, JPG or PNG image.’
      }
      end

    using code below will result in no errors after updating rails50/depot_b/test/controllers/products_controller_test.rb

    class Product < ApplicationRecord
    validates :title, :description, :image_url, presence: true
    validates :price, numericality: {greater_than_or_equal_to: 0.01}


    1. validates :title, uniqueness: true
      validates :image_url, allow_blank: true, format: {
      with: %r{\\.(gif|jpg|png)\\Z}i,
      message: ‘must be a URL for GIF, JPG or PNG image.’
      }
      end
    Vertical bar (as is shown in the book) is correct.
    76OK

    The New Product page generated by scaffold is not like the one shows, but is a little bit messed, as if css has not been correctly applied. What’s wrong?

    This is not enough information to reproduce the problem you are seeing; perhaps we should discuss this on the forum?
    39TYPO

    Choosing a Rails Version

    $ rails _5.0.0.1 —version
    missing underscore

    100ERROR

    … This uses the create!() method …
    but in both the seeds file and the excerpt, it uses create() which doesn’t raise exceptions like promised in text.

    225ERROR

    It seems that some lines are missing , just before the “end” last line of the sample code. These should be the followings:

    > def defaults_url_options
    > { locale: I18n.locale }
    > end

    Actually, the missing lines are already put in the former version of the book ( “Agile Web Development with Rail5” page 214), which make me suppose that these are missing (because no significant change between Rails 4 and Rails 5 on this topic).

    158TYPO

    Now that we have the jQuery-UI library jQuery-UI library available to our application

    Should read

    Now that we have the jQuery-UI library available to our application

    158ERROR

    //= require jquery-ui/effect-blind

    Has changed now to

    //= require jquery-ui/effects/effect-blind
    Using the //= require jquery-ui/effect-blind will result in an error similar to the following

    ActionView::Template::Error (couldn’t find file ‘jquery-ui/effect-blind’ with type ‘application/javascript’

    102ERROR

    localhost link is split with a hyphen. local-host:3000/store/index

    126TYPO

    “…where the cart ID is internal state data residing a cookie.” (missing “in” or “inside” before “a cookie”).

    152ERROR

    The highlighted line in the screenshot is “<% render cart %>" but the text underneath and describing the screenshot reads "From this, we see that the expression being evaluated at the point of error is cart.line_items…”. I suspect it should be just “@cart”.

    215SUGGEST

    def setup
    login_as users(:one)
    end
    end

    “Note that the setup() method will call login_as() only if session is defined.” Perhaps you can explain how this is being inferred? Is this behavior of the ActionDispatch::IntegrationTest class?

    237SUGGEST

    “but the names of the model and the attributes bleed through the interface…We need to provide translations for each.” comes after the screenshot showing the results of providing the translation (so instead of seeing “…que este Order se guarde” in the screenshot and then having the context for the fix, you see the corrected “…que este pedido se guarde” prior to implementing the correction.

    2728ERROR

    I think here where you’ve added
    `assert product.errors[:image_url].any?`

    Meaning we are saying there should be an error if there isn’t an image_url,
    but is that what we really want? We changed the validation to be `allow_blank: true`

    So if the validation allows for it to be blank should we be testing for an error? We won’t get that error anymore, right?

    163SUGGEST

    It would be clearer to write <% render cart %> instead of <%= render cart %> in my opinion, since the string returned by render it isn’t actually rendered, but it’s passed to the hidden_div_if method as a block.

    204ERROR

    rails g scaffold User password:digest

    This creates a database column named password with a ‘type’ of digest. This failed for me because it appears that has_secure_password is looking for a database column/attribute named password_digest.

    17SUGGEST

    The fourth paragraph on page xvi should be rephrased: “So if this book gives you the basics to build on, helps you phrase the right questions, and helps you weed out the conflicting answers that you can find online, then it’s done its job.”

    106ERROR

    When completing Iteration C2 on page 106 of the printed book, we are instructed to create a banner and sidebar by modify the application.html.erb file.

    The code we are instructed to add includes the following line:

    <%= @page_title %>

    The instructions then move on to modifying the application.scss stylesheet.

    However, we run into an error when we are instructed to refresh the browser on page 109 because there was no instruction to create and assign the @page_title instance variable.

    405ERROR

    “Others include an optional :require parameter…” but none of the lines in the sample Gemfile on pages 403-404 actually have “require”.

    406TYPO

    “…when you run the command rails server, a file named config.ruis provided”. In the print version, for some reason, “config.ru” and “is” appear to be concatenated.

    421ERROR

    "First we modify our controller to call paginate(), but that doesn’t correspond to the following source line as there is no call to paginate:

    @orders = Order.order(‘created_at desc’).page(params[:page])

    160TYPO

    In the ‘should create line_item with Ajax’ test you wrote

    assert_select ‘tr#current_item td’, /Programming Ruby 1.9/
    but this is a regex, and the dot is not escaped- now it says ‘any single character’
    it should be

    assert_select ‘tr#current_item td’, /Programming Ruby 1\\.9/

    107ERROR

    The File indicated is : “app/assets/stylesheets/application.scss”
    but there is application.css file generated.

    i.e : “app/assets/stylesheets/application.css”

    109ERROR

    After applying all CSS code for chapter 8, the web forms do not open with the menu displayed in their own side bar (as is the case on page 110). Should

    and

    be converted to and ?
    I would include a screenshot to make this clearer but there does not appear to be a facility for doing this.

    239ERROR

    I added the code to implement the locale switcher. When I selected a different locale, I got an error that there was no route for POST ‘/’. I didn’t see anything about adding a POST route in this section, I added method: ‘get’ to the call to form_tag, and that fixed the error and the locale changed correctly.

    215SUGGEST

    When running the test on p215 I get a stream of error messages, and yet the application is working as expected up to this point.

    It would be useful to give some advice on what might have gone wrong…

    Test results
    DEPRECATION WARNING: Leaving `ActiveRecord::ConnectionAdapters::SQLite3Adapter.represent_boolean_as_integer`
    set to false is deprecated. SQLite databases have used ‘t’ and ‘f’ to serialize
    boolean values and must have old data converted to 1 and 0 (its native boolean
    serialization) before setting this flag to true. Conversion can be accomplished
    by setting up a rake task which runs

    ExampleModel.where(“boolean_column = ‘t’”).update_all(boolean_column: 1)
    ExampleModel.where(“boolean_column = ‘f’”).update_all(boolean_column: 0)

    for all models and all boolean columns, after which the flag must be set to
    true by adding the following to your application.rb file:

    Rails.application.config.active_record.sqlite3.represent_boolean_as_integer = true
    (called from

    at /Users/User/0 RailsDepotApp/depot/test/test_helper.rb:3)
    Run options: —seed 61314

    1. Running:

    Capybara starting Puma…

    • Version 3.11.4 , codename: Love Song
    • Min threads: 0, max threads: 4
    • Listening on tcp://127.0.0.1:60757
      .[Screenshot]: tmp/screenshots/failures_test_creating_a_Product.png
      E

    Error:
    ProductsTest#test_creating_a_Product:
    Capybara::ElementNotFound: Unable to find visible link or button “New Product”
    test/system/products_test.rb:15:in `block in

    bin/rails test test/system/products_test.rb:13

    [Screenshot]: tmp/screenshots/failures_test_updating_a_Product.png
    E

    Error:
    ProductsTest#test_updating_a_Product:
    Capybara::ElementNotFound: Unable to find visible field “Description” that is not disabled
    test/system/products_test.rb:31:in `block in

    bin/rails test test/system/products_test.rb:27

    ..[Screenshot]: tmp/screenshots/failures_test_creating_a_Cart.png
    E

    Error:
    CartsTest#test_creating_a_Cart:
    Capybara::ElementNotFound: Unable to find visible link or button “Back”
    test/system/carts_test.rb:20:in `block in

    bin/rails test test/system/carts_test.rb:13

    .[Screenshot]: tmp/screenshots/failures_test_destroying_a_Cart.png
    F

    Failure:
    CartsTest#test_destroying_a_Cart [/Users/Srjones/0 RailsDepotApp/depot/test/system/carts_test.rb:39]:
    expected to find text “Cart was successfully destroyed” in “HOME\
    QUESTIONS\
    NEWS\
    CONTACT\
    Your cart is currently empty\
    Your Pragmatic Catalog\
    MyString\
    MyText\
    $9.99\
    MyString\
    MyText\
    $9.99\
    Programming Ruby 1.9\
    Ruby is the fastest growing and most exciting dynamic language out there. If you need to get working programs delivered fast, you should add Ruby to your toolbox.\
    $49.50”

    bin/rails test test/system/carts_test.rb:33

    [Screenshot]: tmp/screenshots/failures_test_updating_a_Cart.png
    E

    Error:
    CartsTest#test_updating_a_Cart:
    Capybara::ElementNotFound: Unable to find visible link or button “Back”
    test/system/carts_test.rb:30:in `block in

    bin/rails test test/system/carts_test.rb:23

    [Screenshot]: tmp/screenshots/failures_test_creating_a_Line_item.png
    E

    Error:
    LineItemsTest#test_creating_a_Line_item:
    Capybara::ElementNotFound: Unable to find visible field “Cart” that is not disabled
    test/system/line_items_test.rb:17:in `block in

    bin/rails test test/system/line_items_test.rb:13

    .[Screenshot]: tmp/screenshots/failures_test_updating_a_Line_item.png
    E

    Error:
    LineItemsTest#test_updating_a_Line_item:
    Capybara::ElementNotFound: Unable to find visible field “Cart” that is not disabled
    test/system/line_items_test.rb:29:in `block in

    bin/rails test test/system/line_items_test.rb:25

    .

    Finished in 22.753199s, 0.5713 runs/s, 0.4395 assertions/s.
    13 runs, 10 assertions, 1 failures, 6 errors, 0 skips
    SRJ-MacPro:depot User$

    198179SUGGEST

    Following the tutorial step by step, after updating order.rb, when Checking Out the following ERROR comes:

    SQLite3::ConstraintException: NOT NULL constraint failed: line_items.cart_id

    I solved making a migration, which is not suggested in the book:

    class ChangeCartIdNullTrue2 < ActiveRecord::Migration[6.0]
    def change
    change_column_null :line_items, :cart_id, true
    end
    end

    Regards!

    Categories: