By Developers, For Developers

Historical errata for Rails, Angular, Postgres, and Bootstrap, Second Edition

PDF PgPaper PgTypeDescriptionFixed onComments
21TYPO

Should use port 5000 and not 3000

2016-11-04
6263SUGGEST

for the webpack.config.js, this is not working for me:
module: {
loaders: [
{
test: /\\.css$/,
loader: ‘style-loader!css-loader’
},
{
test: /\\.eot(\\?v=\\d\\.\\d\\.\\d+)?$/,
loader: “file”
},
{
test: /\\.(​​woff|woff)$/,
loader: “url?prefix=font&limit=5000”
},
{
test: /\\.ttf(\\?v=\\d\\.\\d\\.\\d+)?$/,
loader: “url?limit=10000$mimetype=application/octet-stream”
},
{
test: /\\.svg(\\?v=\\d\\.\\d\\.\\d+)?$/,
loader: “url?limit=10000&mimetype=image/svg+xml”
}
]
},

However, changing it to this works well
module: {
loaders: [
{
test: /\\.css$/,
loader: ‘style-loader!css-loader’
},
{
test: /\\.(png|woff|woff2|eot|ttf|svg)(\\?v=[0-9]\\.[0-9]\\.[0-9])?$/,
loader: ‘url’
}
]
},

2016-11-04
12TYPO

Webpack views the problem of serving up CSS as
being compsed of two smaller problems:

2016-11-04
42SUGGEST

In the Gemfile example where you are adding faker, bower-rails is also in the list even though you aren’t using it in this version of the book.

2016-11-29
65SUGGEST

In the code listing for the pager partial, you have three pointer arrows indicating lines of code that need to be modified, but from going through the book this file is entirely new at that point. I think it would make more sense to have every line have a pointer or no lines have a pointer.

2016-11-29
71SUGGEST

The listing showing changes to package.json does not include webpack-dev-middleware but there’s no mention of removing it.

2016-11-29
82TYPO

1st Paragraph under Populate the DOM Using ngFor there is this sentence “First, you need to iterate over the results and render on li for each one”. I suspect instead of on you meant an or one.

2016-11-29
98TYPO

In the code listing for canary_spec.rb, the expectation “expect(false).to eq(true)” is commented out which prevents the example from failing.

2016-11-29
102TYPO

In the description of line 1 of the custom RSpec matcher, constraint_name is misspelled as constaint_name.

2016-11-29
112TYPO

In the first paragraph of section Test the TypeAhead Search, there’s a link back to Chapter 4. The link text does not include the full name of the chapter and it looks odd.

2016-11-29
114TYPO

This is an extension of the report on page 112 regarding links to previous Chapters. After looking more closely I believe whatever tool is generating these links for you is always missing the second line of a two line chapter name. The link to Chapter 5 on this page does it as well.

On page 115 the link to page 82 “Populating the DOM Using ngFor” leaves off the ngFor portion of the section title so it’s not limited to chapter links or names that span two lines.

2016-11-29
119TYPO

In the sentence saying don’t worry about the util.print error, don’t is printed as dont’.

2016-11-29
123TYPO

In the first paragraph of the “Using Test Doubles to Stub Dependencies” section there is this sentence: To avoid that, we’ll stub out the Http class we’re using an runtime. I believe an should be at in that sentence.

2016-11-29
42SUGGEST

Where you show “The Final Customer Table Schema”, you might want to show the rails dbconsole command to describe the table. \\d+ customers

2016-11-29
178SUGGEST

The models for address, state, customers_billing_address, and customers_shipping_address should be changed to inherit from ApplicationRecord instead of ActiveRecord::Base.

2016-11-29
54ERROR

Found this: ““After running bundle install to install the gem, run the webpack_rails:install generator to create the necessary configuration files. ”

Should be: “After running bundle install to install the gem, run the bundle exec rails generate webpack_rails:install generator to create the necessary configuration files. ”

2016-11-29
54SUGGEST

errror #80905
page: 54
Found this: ““After running bundle install to install the gem, run the webpack_rails:install generator to create the necessary configuration files. ”

My apologies… all i had to do was turn the page… There isn’t an issue here.

2016-11-29
179TYPO

In the section Performance Using Active Record, the first sentence has relationships misspelled as relationthips.

2016-11-29
0ERROR

foreman start doesn’t work -
gem thor woa updated thor 0.19.2
with thor 0.19.1 It’s work

github.com/ddollar/foreman/issues/653

2016-12-20
20SUGGEST

last console listing on that page is:
$ bundle exec rake db:migrate

with rails-5 shouldn’t that be
$ bundle exec rails db:migrate

2016-11-29
31TYPO

-First Paragraph
“But it’s not as secure it can be.”

Suggestion: “But it’s not as secure as it can be.”

2016-11-29
ixTYPO

Last line: “where the valuable data saved” replace with “where the valuable data is saved”

2016-12-20
27ERROR

Replace:

<% if @validatable %>

with

<% if @minimum_password_length %>

as “if @validatable” doesn’t work even when declared with the model.

2016-12-20
28SUGGEST

replace

config.email_regexp = /\\A[^]+example\\.com\\z/

with

config.email_regexp = /\\A[\\s]+[@\\s]+\\z/

as this is the default regex generated by devise

2016-12-20
28SUGGEST

Please delete #80939. My mistake :-(

2016-12-20
33SUGGEST

It may be worth noting that after installing webpack and using ruby-2.4.0-pre3 you will get an exception screen when loading the shine dashboard (“ArgumentError: Key should be 32 bytes”, see github.com/rails/rails/issues/26694). The issue should be fixed for rails 5.0.1. Until then the workaround is to use head of the rails-5.0 branch in your Gemfile:

gem ‘rails’, github: ‘rails/rails’, branch: “5-0-stable”

2016-12-20
38SUGGEST

After adding the loaders and the application.css, I ran into an issue with webpack: it kept insisting that I have a CssSyntaxError with the unhelpful error message “Unknown word”. After debugging for a bit, it turns out that the error message was because due to the choice of font in the epub reader on android, the backslash looks very similar to the pipe and I added the regexes for the loaders like so /|.css/. Of course this doesn’t make much sense when you think about it, however due to the stressing of the text of the idiosyncratic syntax I didn’t really think too much about it until I figured out what the css loader was actually complaining about.

So two suggestions:

- state that the first character in the regex is a backslash, just so font-induced confusion doesn’t cause frustration
- add an info box that says that a css syntax error doesn’t neccessarily mean what it says. it could be an error in your webpack configuration files as well

2016-12-20
33SUGGEST

Why not anchor the end of the check regexp as well as the beginning?

I.E. use ‘[]+example\\\\.com$’ instead of ‘[]+example\\\\.com’

2016-12-20
43SUGGEST

Some suggestions for the db seeds script:

- First, wrap the code in if Rails.env.development? so that you can use the same script to set up lookup tables in staging and prod environments
- Second, the script is so slow because you aren’t using transactions. The way it’s written each create! call is inside its own transaction, and commiting transactions creates some overhead for postgres (all the unique indexes and constraints are checked again on a transaction commit, in case there is a collision with data that got commited in the meantime by another transaction). Using transactions and adding records in batches of 1000 like the following let the script run in ~8.5 minutes for me:

350.times do |i|
Customer.transaction do
1000.times do |j|
Customer.create!( first_name: Faker::Name.first_name,
last_name: Faker::Name.last_name,
username: “#{Faker::Internet.user_name}#{i * 1000 + j}”,
email: “#{Faker::Internet.user_name}#{i * 1000 + j}@#{Faker::Internet.domain_name}” )
end
print “.”
end
end

2016-12-20
44SUGGEST

I’m confused as to why the examples are using the h1 tag and classing it to h2 and h3. Why not use the corresponding tags themselves?

2016-12-20
anySUGGEST

With all the bootstrap classes introduced as the book progresses, maybe an appendix with a listing of the classes and a short explanation where they’re supposed to be used would be useful.

Also, what does the suffix “-lg” stand for? We’re using it in several places, but I haven’t seen an explanation for it yet. Is it “long” or “large” or something else?

2016-12-20
47SUGGEST

Maybe state in a short sentence why we’re using lower(x) LIKE ‘’ here instead of the functionally equivalent x ILIKE ’’ (presumably because of functional indices created later on).

Also, maybe mention the ci_text postgres extension in a footnote that would make case insensitive comparisons transparent on the sql/query level.

2016-12-20
52ERROR

EXPLAIN ANALYZE in postgres does not just get the query planners execution plan for the query given, it actually executes the query in order to get the timing results. This means that if you execute the EXPLAIN ANALYZE multiple times, postgres will access its query cache. While this doesn’t impact the query here, due to the sequential scan taking up the bulk of the time, it will have impact on queries where a lot of the time is spent waiting on IO for data that needs to be loaded from disk into memory.

A better way would be to use the \\timing command within the dbconsole and execute the query directly to get a feel for the runtime of the query and just use EXPLAIN without ANALYZE. This way the output of the explain statement is idempotent regardless of the query cache, as the query itself is not executed.

2016-12-20
33SUGGEST

The `email_must_be_company_email` sounds like `butter_must_be_buttery`. Maybe changing it to `email_must_have_company_domain` would better reflect the constraint’s purpose?

2016-12-20
71ERROR

Chapter 6: Build a Dynamic UI with AngularJS - Install Angular

Trying to install Angular after copying the dependencies listed in the given package.json. I had a few ‘npm WARN unmet peer dependencies’ for rxjs and zone.js, and read that the versions required were just not matching. Here are the errors:

shine@0.0.1
|—- UNMET PEER DEPENDENCY rxjs@5.0.0-beta.12
|—- UNMET PEER DEPENDENCY zone.js@0.6.26

npm WARN angular/core2.3.0 requires a peer of rxjs@5.0.0-rc.4 but none was installed.
npm WARN angular/core2.3.0 requires a peer of zone.js^0.7.2 but none was installed. npm WARN angular/http@2.3.0 requires a peer of rxjs@5.0.0-rc.4 but none was installed.
npm WARN angular/router3.3.0 requires a peer of rxjs@5.0.0-rc.4 but none was installed.

I haven’t used npm or Node much so I’m not sure if npm WARN really matters much, but I figured changing the versions to match the ones they were asking for would work. After changing them, I didn’t get the errors. Not sure if we should use the versions they are asking for or the ones listed in the book. Anyway, just wanted to bring issue up to get some clarity.

2016-12-20
74SUGGEST

In the angular test javascript input into application.js, the input form id, input form model, and, angular model are all called “name”. It would be easier to see what connects with what in the code and template if these were set to different string values. Currently it’s a huge muddle of “name”s.

2016-12-20
648ERROR

Chp. 1 / Section “Setting Up Bootstrap with Yarn and Webpack”. When running “bundle exec generate webpack_rails:install” 

received following error.
“/usr/local/rvm/gems/ruby-2.3.0/gems/thor-0.19.4/lib/thor/actions/inject_into_file.rb:95:in `binread’: No such file or directory @ rb_sysopen - /home/ubuntu/workspace/.gitignore (Errno::ENOENT)”

to fix issue I had to research, but it came down to “.gitignore” file not being setup. Should this have happened by itself or did the book miss telling me this?

2016-12-20
10TYPO

yarn installs node packages to node_modules, not node_models.

2016-12-20
102SUGGEST

I would suggest not just placing the given constraint name in the regular expression, as regex special characters would be evaluated as such. Instead escaping the name beforehand makes the code safe: /#{Regexp.escape( constraint_name )}/

OTOH, if you’re expecting the parameter value to be used as a regular expression, the parameter name should be changed from “constraint_name” to reflect the this.

2016-12-20
109SUGGEST

Don’t use the rather generic variable name “$pid”, rather call it so it’s clear what it contains e.g. “$webpack_server_pid”.

2016-12-20
88TYPO

You’ll need to create app/views/customers_pager.html.erb, and I’ve highlighted the
should be
You’ll need to create app/views/customers/_pager.html.erb, and I’ve highlighted the

2016-12-20
119SUGGEST

Maybe draw attention to the fact (and give a reason why) the javascript spec filenames are CamelCase whereas the ruby standard (and also the canaray.spec.js file) have been using snake_case.

2016-12-20
122SUGGEST

Maybe highlight the fact that jasmine does not mark unimplemented tests as “pending”, but counts them as successes, as opposed to rspec.

2016-12-20
125SUGGEST

The explanation of the mocking of obversable.subscribe() is rather hard to understand, I guess partially because some intuitive understanding is assumed and partially because the explanation is divided by the code block.

Things that I don’t understand after multiple readings of these paragraphs:

- is td.callback(response) verifying that when the callback is called, that response is passed, or are we mocking the parameters of the callback function here?

- is td.matchers.isA( Function ) a matcher on the second parameter to subscribe (and will thus accept anything that is a function) or is it a matcher on the first parameter (which needs to be a function as well)?

2016-12-20
126TYPO

The string parameter of the describe block “A successful search” was “A search for ‘pat’, three or more characters” on the previous pages.

2016-12-20
127TYPO

The error output looks different for me, the main error message is ‘Reference Error: alert is not defined’. Probably because we didn’t call window.alert() as the text states, but just alert(). Changing the angular code to explicitly call window.alert() causes the error message to be “Reference Error: window is not defined”.

After following the rest of the section, it turns out that the angular code indeed needs to be changed to call window.alert() instead of a naked alert() in order for the mock to be successful. This means the code on PDF page 81, 87 and 92 needs to be changed to call window.alert().

2016-12-20
10TYPO

Note that Procfile was created by the webpack-rails generator we jsut ran

should be

“we just ran”

2017-01-06
147SUGGEST

In the interest of clean, easy to understand code I’d suggest being explicit in the casting by using parseInt( params[‘id’] ) instead of +params[‘id’]. While the later may be known ot people who write lots of javascript, it’s not really intuitive (or known) to people who only occasionally write javascript.

2017-01-06
98SUGGEST

On this page the rspec tests are executed using rails spec, while afterwards it seems that they are always called directly using rspec. This is a bit confusing - when should one use rails spec and when should one use rspec directly? A short explanation would help.

2017-01-06
109SUGGEST

Can the webpack server for the test environment be configured to run on a different port than in the dev environment? It’s a bit annoying to either have errors displayed in the console when running tests while foreman is still running, or having to stop and restart foreman whenever we want to run tests.

2017-01-06
151ERROR

Testing component.customer in the initial state seems to be an error since in the constructor of CustomerDetailComponent on page 147 we did not set up a customer attribute, but an id attribute that should be null. I’m guessing the test should be expect( component.id ).toBe( null ); ?

2017-01-06
98ERROR

I just ran into the issue detailed here: stackoverflow.com/questions/13410631/how-to-solve-privileges-issues-when-restore-postgresql-database
Running `psql` and entering the command `alter role shine with superuser;` fixed it.

2017-01-06
151SUGGEST

Disregard the Technical Error I submitted previously. After reading the rest of the chapter, things clicked into place. What threw me off was the passage

“This is the same boilerplate you’ve seen before, plus a basic test of our con-
structor (namely, that it sets its customer property to null ). Next, let’s create the
shell of our test for ngOnInit . The contract of ngOnInit is to set the property customer
to an object it receives from the back-end.”

The phrasing suggested to me that this contract is what we had already previously implemented, instead of being what we’re aiming for. I would suggest rewording to avoid confusion for the reader, to make it explicit that the tests are not going to reflect what we’ve implemented in the previous chapter, as we’re already aiming to test the final implementation with the tests that are being written here.

2017-01-06
187SUGGEST

It would be easier to read the SQL queries containing joins if the order of tables given in ON-clauses are always the same, i.e.

JOIN A_table ON ( A_table.id = B_table.id )

or

JOIN A_table ON ( B_table.id = A.table_id )

Currently, both orders are used. Especially in a query with lots of JOINs - such as the CREATE MATERIALIZED VIEW query - it’s easier to grok with a uniform ordering in the relation.

2017-01-06
196ERROR

“With that in place, our tests should be passing again.”

This is actually not true, the Customer Search feature “search by email” should be failing, since in the previous chapter we’ve hardcoded the user detail values to Bob Jones (qv page 164). I’ve just spend 30 minutes debugging the rails/angular interaction, wondering why this test was failing. But yes, when you follow the code along with the book, it should be failing.

2017-01-06
165ERROR

The values of the customers attributes in the screenshot do not match the values of the code on the previous page (screenshot: Pat Jones, pattyj@somewhere.net, html: Bob Jones, bobbyj@somewhere.net). All the following screenshots reflect Pat Jones, but the template is never updated to replace Bob with Pat. The Appendix containing the HTML template for the customer details does hardcode Pat Jones.

Also, it should be noted to the reader that if the tests are all green at the end of the following chapter, this is only because the values in the Customer Details template are hardcoded to match the values in the feature specs mock customers, it should not indicate that the CustomerDetails template is actually fully functional.

2017-01-06
202SUGGEST

The one (IMO quite important) thing that the observable description does not mention is if functions subscribed to the same observable are invoked in any guaranteed sequence, and if they are called serially or asynchronously (i.e. is there an invocation order on setCustomer and requestCardInfo?). Just knowing if even within the callbacks of an observable there are no guarantees as to when they are invoked can be quite enlightening.

2017-01-06
120SUGGEST

This line: “First, place all the code for CustomerSearchComponent into the file webpack/Custom-erSearchComponent.js .”
I initially extracted all code related to CustomerSearchComponent out into that file.
I accept I’m dumb, but I suspect I’m not the only one. :)

2017-01-06
73SUGGEST

The javascript require by itself is easy enough to understand for ruby people, however the syntax of require( "angular/<subcomponent>") is odd. Is the part of a special syntax? If so, what does it mean? Or is it just part of the exported angular module name? If so, why did the angular people choose to do this? A short footnote would be helpful to fully understand what is happening here.

2017-01-06
9TYPO

In Chapter 1, page 9 of the PDF, within the first paragraph, you have the following slightly incorrect command:

bundle exec rails webpack_rails:install

Within the code snippet (terminal log) that follows you have the correct command that includes the omitted word, generate:
bundle exec rails generate webpack_rails:install

2017-01-06
Ch 12SUGGEST

in Chapter 12, during the “Saving Changes to the Server” section, there’s no mention I’ve found of having to update the config/routes.rb file by changing resources :customers, only: [ :index, :show ] to resources :customers, only: [ :index, :show, :update ]

2017-01-06
227SUGGEST

The explanation of ref-firstName=“ngModel” is a bit unsatisfactory. Basically it just says “this is the way you have to do it” instead of saying why we have to do it this way. Why do we need to put a type (ngModel) into the attributes value, when we’ve placed variable names there before? Can we use other values besides ngModel? Would I be able to bind another variable name here and use that in an equivalent fashion - and if not: why not?

2017-01-06
228SUGGEST

When giving the code snippet for

I’d mention that the logic can be extracted into a component class method that can be called from the code in the bind, akin to Rails helpes, and that you’ll show how later in the chapter. This was the first question that sprung to my mind after seeing the snippet.

2017-01-06
228SUGGEST

A bit more detail here on the bind-class attribute would be nice: Can any javascript code be embedded here? When is the bound code evaluated?

2017-01-06
231SUGGEST

The explanation of attr.for is actually a critical part for understanding how angular works and why we’re doing things that we’re doing. After reading this part things clicked into place for me that I’ve considered odd and ideosyncratic about angular up until now: that apparently the markup we’re writing in the templates is not HTML markup that gets parsed and parts evaluated and replaced, but that we’re actually defining and configuring angular objects that will in turn be turned into html during rendering. This is a very important distinction to make, since you’re effectively writing HTML5 in the template but in a configuration language that looks like HTML5 (and will probably evaluate to the same HTML text in the end - however this raises the question of how angular treats unknown tags and attributes in its templates. Can we just use new HTML markup as it’s implemented in the browsers, or do we need to wait for angular to catch up?)

I would stress this explicitly in an info box in the chapter where angular gets introduced. It would make many things clearer as the book progresses.

2017-01-06
240SUGGEST

In the code snippet example for the emit() function, it’s confusing where the model variable suddenly comes from, as it’s not defined in the code changes we’ve made up until now. That model is a parameter of the (not shown) encapsulating function only becomes clear at the bottom of the next page.

2017-01-06
249SUGGEST

I strongly disagree with your reasoning on why rails validations are not neccessary (beyond the scope of this simply example application, or you’re a one-man shop that controls the entire infrastructure).

Even for an internal admin interface you cannot guarantee that all requests will solely be coming from the angular code that we wrote - be it that some enterprising new employee in the Customer Support department wrote a shell script using curl to automate some tasks, or another frontend interface starts working with the JSON REST API that the server is exposing. On the server side ALL input should ALWAYS be seen as coming from an untrusted (and unknown) source. Especially in a world that is rapidly adopting microservices and distributed systems.

Another scenario is that a collegue is tasked with changing the data store of the data we’re saving here. If this person does not know about how important the database checks are, they might leave it out of their implementation because it’s not feasable or too hard in the new datastore, or they have very little time. And then your application is suddenly missing very important validations.

Also, leaving the validation to the database creates performance issues. It’s a lot better to validate what you can before hitting the database, in order to keep as much load from the database as possible.

All in all, validations should be done in each tier of the application. It may be annoying at times, but it creates a more robust application down the road.

That being said, would I add rails validations for this example application? No, that would be overkill, I agree. However please rephrase the corrsponding passage to not imply that validations in the frontend and the database are enough.

(I’ve worked with people who unreflectingly just apply what they’ve read in books to anything they’re currently working on, and the pain they created for everyone else down the road is something that noone else needs to experience :) Just to explain why I’m so passionate about this subject)

2017-01-06
1SUGGEST

Similar to my bootstrap suggestion, but for angular: as the book progresses, we’re using more and more special tags in the templates: bind, bindon, on, ref, ngIf, *tags etc. An appendix with a short overview of the tags used in the book and what they do would be a great help when trying to look something up later, after reading the book, and you don’t quite remember where it was introduced.

2017-01-06
CH1TYPO

For installing webpack in the introduction CH. 1 it says `bundle exec rails webpack_rails:install` but this should be `bundle exec rails generate webpack_rails:install` as in the second mention in the code example. Also I get the two questions in opposite order, which might sooner lead people to accidentally answering yes where no or vice versa.

2017-01-06
248SUGGEST

In the definition of address_attributes, you write State.find_by_code(). However in previous AR-find_by statements, you’ve used the Model.find_by( attr_name: value ) style. Since both are equivalent, I’d suggest using find_by() here as well, in order for the finder invocations to all look the same.

2017-01-06
Ch1ERROR

After passing CH. 1 I get this error (in CH.2):

bundle exec rails db:migrate
rails aborted!
ActiveRecord::StatementInvalid: PG::InsufficientPrivilege: ERROR: permission denied for relation schema_migrations
: SELECT “schema_migrations”.* FROM “schema_migrations”
bin/rails:4:in `require’
bin/rails:4:in `


PG::InsufficientPrivilege: ERROR: permission denied for relation schema_migrations
bin/rails:4:in `require’
bin/rails:4:in `


Tasks: TOP => db:migrate
(See full trace by running task with —trace)

Have yet to solve it, but did everything the book said.

2017-01-06
271TYPO

in the second paragraph, the first sentence should read “… an older version of the shim in package.json”

currently it reads “… an older version of the ship in package.json”

2017-01-06
179SUGGEST

The load of addresses here has taken an hour at least — I’ve lost track!
Would loading a dump of a development tables not be quicker here?
It could be done in MySQL, so I guess it could be done in PostgreSQL.

2017-01-06
71ERROR

I got an error at the following line in class CustomerSearchTerm
search_term = search_term.downcase
When I changed the line to the following, It worked fine.
search_term = search_term.to_s.downcase

2017-01-06
113TYPO

“YOu’ll re-create” should be “You’ll recreate” Beginning of first paragraph. Mid page.

2017-01-15
77TYPO

“passed to ng.core.Copmonent’ should be ”passed to ng.core.Component" Last Paragraph of Page

2017-01-15
10TYPO

“we jsut ran” should be “we just ran”

2017-01-17
190ERROR

Since customer_details has only 350,000 rows,
Change from:
sql> select * from customer_details where customer_id = 388399;
to:
sql> select * from customer_details where customer_id = 348399;
Below this likewise,
customer_id | 348399

2017-02-26
251TYPO

Second line:
“as shown in the followingn screen” should be “as shown in the following screen”

2017-02-26
57TYPO

Regarding the following line of text: “The version of Node shouldn’t matter too much, but this book was written using version 7.2.0”.

Back on page 42, the version of Node listed is 6.3.0. Pointing out the inconsistency.

2017-02-26
57TYPO

“Visit Yarn’s intall page”. Should be “install page”

2017-02-26
64TYPO

“because they tell Webpack how to load particular file”

Missing “a” between “load” and “particular”

2017-02-26
266SUGGEST

I’m getting a duplicate page here: pages 266 and 267 are identical.

2017-02-26
272TYPO

“similiar” should be “similar”

“naivgate” should be “navigate”

2017-02-26
287SUGGEST

I missed the change to which component was bootstrapped in the Angular code, so I ended up with an application that redirected correctly…to a blank page. It’s obviously beyond the scope of this book to address every possible way that something can be set up incorrectly. But in this particular case I found myself wishing for something along the lines of “if the page is blank, go back and make sure everything is set up correctly in the angular component.”

2017-02-26
305TYPO

The describe has a doubled/repeated ‘Component’ word: CustomerDetailsComponentComponent instead of just CustomerDetailsComponent

2017-02-26
308TYPO

Quote: “but I’ll leave that an exercise”
Missing “as” between “that” and “an”

2017-02-26
361TYPO

Quote: “This is still pretty fast, but it’s certainly slower as all seven…”
Feels like the word “as” should be “than”

2017-02-26
201TYPO

An inner join is way to tell Postgres not to return data if there isn’t data in a
related table.

Should be:

An inner join is a way (etc…)

2017-02-26
218TYPO

3rd paragraph, first sentence:
“This is exactly the same setup we want to acheive here.”

Typo is “acheive”, change to: achieve

2017-02-26
226TYPO

2nd line under the routes.rb code block:
request /credit_card_info/«cardholer_id» and…

should be cardholder_id

2017-02-26
228TYPO

First two sentences of the page:
That’s because that is when we knew the customer ID whose data should be
fetched. When will know the cardholder ID?

u wot m8?

Ahem Context: talking about where to put the code for requesting the credit card info

2017-02-26
251TYPO

End of sentence and second line:

…as shown in the followingn screen.

Should be:

…as shown in the following screen.

2017-02-26
261TYPO

Topic is about using arrays in Postgres.

First paragraph of the page, second sentence:

“Suppose we want to find all the users with the role edit_shipment.”

I think you meant “edit_customers” and not “edit_shipment”, as seen in the roles array of the SQL example given.

Also, second paragraph, first sentence/second line has a similar typo:
“…with the literal ‘edit_shipment’ we used.”

2017-02-26
15TYPO

require (“application.css”);
console.log(“Hello World”);

should be:

require(“application.css”);
console.log(“Hello World”);

There’s a space between the require and right paren.
Probably not too big a deal, but it’s different from page 16

2017-02-26
86SUGGEST

Page 86 states “Because JavaScript has no official way to define a class, you’re using the mechanism Angular provides…” The sentence should read “Because the class keyword was not introduced into JavaScript until version ES6(2015), and we are using ES5(2009) in this book, we will use the mechanism Angular2 provides…” I think this clarification would be helpful because, from what I have seen anecdotally here in New York City, ES6 is quite successful and is being adopted fairly rapidly by front-end developers.

2017-06-07
103SUGGEST

Page 103: “[In RSpec] we’re explicitly requiring the expect() syntax—you don’t want to use the .should assertions because this would be counter to our desire for our Ruby and JavaScript tests to be similar.” While it is true that the Jasmine (JavaScript) unit test library does not natively support “should” style assertions, it is quite common for JavaScript developers to use chai, a nice little library that is compatible with Jasmine and which provides should(). I personally prefer should() as I think it reads more naturally than the expect() style.

2017-06-07
147ERROR

Page 147: “Angular2 does not use “#” in routing URLs”. Actually, that is not correct. It is true that by default Angular2 does not use hash (#) for routing URLs, but you can turn them on if you want to via a simple one-line configuration change.

2017-06-07
131SUGGEST

When adding the observable code I found it hard to know where to enter it. I had to refer to the source code in the end.

Here is what I had before looking at the source code;

beforeEach(function(){
var response = td.object([“json”]);
td.when(response.json()).thenReturn({customers: customers});
mockHttp = td.object([“get”]);
component = new CustomerSearchComponent(mockHttp);

var observable = td.object([“subscribe”]);
td.when(observable.subscribe(
td.callback(response),
td.matchers.isA(Function))).thenReturn();

mockHttp = td.object([“get”]);
td.when(mockHttp.get(“/customers.json?keywords=pat”)).thenReturn(observable);
});

and here is what I had after;
beforeEach(function(){
var response = td.object([“json”]);
td.when(response.json()).thenReturn({customers: customers});

var observable = td.object([“subscribe”]);
td.when(observable.subscribe(
td.callback(response),
td.matchers.isA(Function))).thenReturn();

mockHttp = td.object([“get”]);
td.when(mockHttp.get(“/customers.json?keywords=pat”)).thenReturn(observable);

component = new CustomerSearchComponent(mockHttp);
});

Maybe a little note on page 131 like the following would help;

Add this code in between the following two lines in the beforeEach

td.when(response.json()).thenReturn({ customers: customers });
// Enter in here
mockHttp = td.object([“get”]);

2017-06-07
74ERROR

directives are deprecated in Angular 2, and they send away error ts2345.

There are some changes needed (i.e. you need to declare it in @NgModule) to make it work.

I am using Rails 5.1 and webpacker, so my configuration is different, but here you have my pomodorotimer.module.ts
import { BrowserModule } from ‘angular/platform-browser'; import { NgModule } from 'angular/core’;

import { PomodoroTimerComponent, CountdownComponent} from ‘./pomodorotimer.component’;

@NgModule({
declarations: [
PomodoroTimerComponent, CountdownComponent
],
imports: [
BrowserModule
],
providers: [],
bootstrap: [PomodoroTimerComponent]
})
export class PomodoroTimerModule {}

And I needex to export the class in export class CountdownComponent to make it available to @Ngmodule

2017-06-07
202ERROR

“With that in place, our tests should be passing again.”

…At this point, only with some more work. In Chapter 9 the CustomerDetailsComponent was changed to have hard coded values in it (presumably because the layout was more important than the data). There is a test in customer_search_spec.rb, that looks within customer-details and expects to find data from the database. So either the CustomerDetailsComponent needs to be reverted back (to what it was on PDF page 163), or the test (at the bottom of PDF page 155) needs to be modified.

2017-06-07
219TYPO

The

has grown a customer-info class and is now being protected with *ngIf=“customer”. If these are necessary (not sure they are), line needs highlighting with arrow and an explanation would be good.

2017-06-07
221TYPO

The “observable” var is being declared for the first time. Line needs highlighting with arrow.

2017-06-07
56SUGGEST

The second paragraph states, “Rails doesn’t provide a way to do this with Active Record’s migrations API, but it does provide a method, execute, which executes arbitrary SQL.” and then goes on to explain in the paragraph after the migration that “Rails 5 added the ability to create these Postgres-specific indexes using add_index.”

So it seems to state flat out that execute HAS to be used in the first paragraph, but then goes on to use the new Postgres specific add_index in the paragraph after the migration bit.

2017-06-07
83TYPO

“even” should be “event” in “You’ll write code to respond to a click even in our search…”

2017-06-07
118ERROR

I don’t believe the book ever instructs the user to setup and configure EasyScreenshots. The setup-poltergeist code branch contains the file testing/setup-poltergeist/shine/spec/support/easy_screenshots.rb and the rails-helper contains the code to configure it:

~
# spec/rails_helper.rb, Line 31
config.add_setting :screenshots_dir
config.screenshots_dir = “#{::Rails.root}/spec/screenshots”
config.include(EasyScreenshots, type: :feature)
~

It was at this point in the book that I was getting errors about easy screenshot. After adding the easy_screenshots.rb file and the configuration into rspec_helper.rb, it started to work.

2017-06-07
5373ERROR

1) CustomerSearchComponent search A search for ‘pat’, three or more characters A search that fails on the back-end sets the keywords to be ‘pat’
Message:
ReferenceError: alert is not defined
Stacktrace:
ReferenceError: alert is not defined
at Array. (/Users/victor/projects/shine/webpack/CustomerSearchComponent.js:70:9)
at /Users/victor/projects/shine/node_modules/testdouble/lib/store/stubbings.js:83:28
at arrayEach (/Users/victor/projects/shine/node_modules/lodash/_arrayEach.js:15:9)
at Object.forEach [as each] (/Users/victor/projects/shine/node_modules/lodash/forEach.js:38:10)
at invokeCallbackFor (/Users/victor/projects/shine/node_modules/testdouble/lib/store/stubbings.js:77:14)
at executePlan (/Users/victor/projects/shine/node_modules/testdouble/lib/store/stubbings.js:51:5)
at Object.invoke (/Users/victor/projects/shine/node_modules/testdouble/lib/store/stubbings.js:33:14)
at Object.testDouble [as subscribe] (/Users/victor/projects/shine/node_modules/testdouble/lib/function.js:37:24)
at ng.core.Component.Class.constructor.search (/Users/victor/projects/shine/webpack/CustomerSearchComponent.js:65:7)
at jasmine.Spec. (/Users/victor/projects/shine/spec/javascripts/CustomerSearchComponent.spec.js:107:21)

2017-06-07
8TYPO

Visit Yarn’s intall page12 to find instructions for your operating system.
- Install misspelled. Missing ‘s’

2017-06-07
80TYPO

“A components can be thought of as a model, view, and controller all wrapped up into one.”

Should be “A *component…” in the singular form

2017-06-07
32ERROR

Under “Install and Configure Webpack”, the command ‘bundle exec rails webpacker:install’ is given. However, if instructions have been followed to this point, this will not work, as Rails 5.1 is required, and all instructions previous to this point install Rails 5.0 (screenshots before this point show 5.0.0.1, but after this paragraph we are magically on 5.1.0.rc1!)

While the instructions provided will eventually work once 5.1.0 is released, it would be useful for there to be a note somewhere — either in the book or on the errata site — telling people how to get pre-release versions without running into messages like ‘Bundler could not find compatible versions for gem “railties”’.

Either way, the previous screenshots need updating :)

2017-06-07
36ERROR

The 1.1 version of webpacker that is bundled with rails 5.1.0.rc1 uses a config/webpack/loaders folder to store loaders, rather than patching things on to the end of module/rules in config/webpack/shared.js, and the loader code in the book should probably conform to this (especially since this is more in keeping with the Rails way of doing things :)

2017-06-07
73ERROR

The supplied package.json is no longer valid for Rails 5.1 — particularly, server startup fails without extract-text-webpack-plugin installed.

I needed to add the following lines (and update some other version numbers to those supplied by default under Rails 5.1):

“autoprefixer”: “^6.7.7”,
“extract-text-webpack-plugin”: “^2.1.0”,
“js-yaml”: “^3.8.3”,
“node-sass”: “^4.5.2”,
“postcss-loader”: “^1.3.3”,
“postcss-smart-import”: “^0.6.10”,
“precss”: “^1.4.0”,
“sass-loader”: “^6.0.3”,
“webpack-manifest-plugin”: “^1.1.0”,

2017-06-07
110SUGGEST

Rails 5.1 now has built-in database cleaning for JS tests (edgeguides.rubyonrails.org/5_1_release_notes.html#system-tests) — could this section be updated to reflect the new way of doing things? It would be good if the whole testing setup section reflected Rails 5.1’s built in Capybara support, as a good chunk of it appears to be superfluous now.

2017-06-07
2TYPO

This has been touched on by another post, but here’s an additional detail. The list of software version numbers has Rails at 5.1. But after the “gem install rails” command is: “…get the latest version of Rails, which is 5.0.0.1 as of this writing.”

2017-06-07
293SUGGEST

For “Appendix 2: Creating Customer Address Seed Data”, the db:seed took a really long time. Would it be better to wrap the “Customer.find_each do |customer|” block in a transaction or do a bulk-insert? I’d imagine 350,000 separate inserts would rack an SSD as well.

2017-06-07
73TYPO

looks like the following lines are missing from typeahead/install-angular/shine/package.json on page 73-74:
“extract-text-webpack-plugin”: “^2.1.0”,
“webpack-manifest-plugin”: “^1.1.0”,
“webpack-merge”: “^4.1.0”

2017-06-07
3SUGGEST

The Rails `—webpack` option installs webpacker and “TypeScript support and the Angular core libraries will be added via yarn and changes to the configuration files made.”

`$ rails new shine \\
—> —webpack=angular \\
—skip-turbolinks \\
—skip-spring \\
—skip-test \\
-d postgresql`

From //github.com/rails/webpacker

2017-06-07
8TYPO

While we could install Webpack directly and set it up by hand, Rails 5.1 includes a gem called Webpacker that is the support way to use Webpack in a Rails application.

2017-06-07
8ERROR

The “rails webpacker:install” command on this page fails. When you say “Rails 5.1 includes a gem called Webpacker that is the support way to use Webpack in a Rails application.” — it only includes webpacker if you use the “—webpack” argument to “rails new”.

So either add “—webpack” to the “rails new shine” on PDF p. 3 — or else add the “webpacker” gem to the Gemfile before the “rails webpacker:install” command.

2017-06-07
48TYPO

“Armed with this knowledge, as well as our helper method extract_name_from_email,
you can now implement build_for_email_search.”

Method is call extract_name not extract_name_from_email

116TYPO

> NODE_ENV=test $(yarn/bin)/karma start spec/javascript/karma.conf.js \\
should be
> NODE_ENV=test $(yarn bin)/karma start spec/javascript/karma.conf.js \\

remove “/”

272TYPO

Sentence “Be sure to get the latest version of Rails, which is 5.0.0.1 as of this writing” should probably be updated to a 5.1 version, since the rest of the book has been rewritten for 5.1 :)

79TYPO

“Because has no official way to define a class, you’re using the mechanism
Angular provides.”

Presume this should be “Because JavaScript has no official…”

134110TYPO

“sophisitcated” should read “sophisticated”

69TYPO

I think I found two typos at the top of PDF page 69, 1st para, 2nd & 3rd sentences:

“What this help does is to bring in a file that’s inside app/javascript/packs. If you look in that directory know, you’ll see the file hello_angular.js.”

‘help’ should be ‘helper’
‘know’ should be ‘now’

HTH.

98TYPO

“Any arguments given to the matcher are passed to
the block as arguments. We’ve named the argument we’re expecting constant_name.”

Should be constraint_name

114TYPO

Let’s try running our test:
> NODE_ENV=test $(yarn/bin)/karma start spec/javascript/karma.conf.js \\

Should be $(yarn bin)

138114TYPO

$(yarn/bin) should be $(yarn bin) in the test running command.

156132ERROR

The code added to app/javascript/packs/customers.js under “Install and Configure Angular’s Router” duplicates code that has just been added in the section above (Create a Bare-Bones Second Component). It might not be necessary to import Component in that first section, but it certainly isn’t necessary to import RouterModule at that point :)

157133TYPO

When adding “router” to CustomerAppModule’s imports, this should read “routing” as this is what we’ve defined just above.

172148TYPO

In the second code listing, the import { Http } line should have an arrow next to it, indicating it is new.

256234ERROR

validationPattern is defined in the code sample above the paragraph starting “Now, let’s create a test for validationPattern”. It’s then defined again below. Should probably be omitted from the first sample.

256234TYPO

The line
return !(model.invalid && model.dirty);
should read
return !(model.valid && model.dirty);
as model.invalid is not defined.

282261SUGGEST

The text says “you can also give to_tsquery a config name”, but the example code shows a config name being give to to_tsvector instead. While both functions can accept a config, it would be less confusing if the text mentioned that both functions could accept a config name.

290269TYPO

In the paragraph immediately before the “Extracting Reusable Code into Services” heading, “They can be quiet sophisticated” should read “They can be quite sophisticated”.

122TYPO

ERROR: “We’ve named the argument we’re expecting constant_name.”

CORRECTION: “We’ve named the argument we’re expecting constraint_name.”

It’s constraint_name not constant_name.

190ERROR

“With that in place, our tests should be passing again.”

Customer Search Search by Email still fails:
Failure/Error: expect(page).to have_content(customer.id)
expected to find text “5” in "Customer …

This is because the new view no longer has the customer id so suggest this test be removed.

xixTYPO

Page number missing from link: “figures on page xx”

xxiiTYPO

Incomplete chapter name: “Chapter 9, Design Great UIs with, on page 155”. Should be “Design Great UIs with Bootstrap’s Grid and Components”

157133ERROR

Bottom of page: Adding ‘router’ to imports array should be ‘routing’. Otherwise, it throws an “Uncaught ReferenceError: router is not defined” in the web console.

133ERROR

The variable name for RouterModule should match the name in CustomerAppModule#imports, i.e., they both should be ‘router’ or ‘routing’.

27ERROR

“Be sure to get the latest version of Rails, which is 5.0.0.1 as of this writing.”

Two pages ago it said the book is written for “Rails 5.1.1”.

46SUGGEST

The CustomerSearchTerm#build_for_name_search sets @order to “last_name asc”.

The problem is that should there be many customers with the same last name, this ordering might not be unique between runs of the query, postgresql will return differently ordered results with different LIMIT and OFFSET values.

For the pagination to work as expected, we need to order on something unique. I replaced the @order string with “last_name asc, username”.

Similar argument can be made for the search by email functionality.

31SUGGEST

I thought this was a typo but its actually just a tricky bit that might be nice to have mentioned in a small note…

Within the up method definition, the regex

`[@]+example\\\\.com$

correctly contains 2 backslashes — the escape backslash must itself be escaped with another backslash because its within a %{} string literal. But this is confusing because we see this same regex with only 1 backslash earlier (in the Devise config) , and again later (migration output).

64-65SUGGEST

1/ add the number of Results and check next page with if :
——————— in customers_controller.rb :
order(customer_search_term.order) # i remove " . " here
totalresultat = customers.count.to_i
customers = customers.offset(PAGE_SIZE * page).limit(PAGE_SIZE) -------------- in views/customers/_pager.html.erb : search with less than 10 should not show next page ------ % if totalresultat > customers.count %> <li class="next"> <%= link_to "Next &rarr;".html_safe, customers_path(keywords: keywords, page: page + 1), title: "Next Page" %> <% end %> </li> ---------------- in /views/customers/index.html.erb : to show total results count --------- <h1 class="h3"> <%= totalresultat.to_s if @nomenclatures.count > 0 %> Results


thank you so much , i like your book it’s great , i learn a lot with it as a newbee , those humble suggestions are only my thoughts of need maybe other peoples think of it also and find it useful ..

123ERROR

bundle exec rake rspec SPEC=spec/models/user_spec.rb

should be:

bin/rails spec SPEC=spec/models/user_spec.rb

4ERROR

while ‘bundle exec rails db:create’ got this error:
Bundler::GemRequireError: There was an error while trying to load the gem ‘uglifier’.
Gem Load Error is: Could not find a JavaScript runtime. See h.ttps://github.com/rails/execjs for a list of available runtimes.

solved it by:
sudo apt-get install nodejs

Kindl3010ERROR

Chapter 6

customers.js

var CustomerSearchComponent = Component({ x -
Uncaught TypeError: Object(…)(…).Class is not a function

10ERROR

I encountered an error when trying to run ‘foreman’ the way described in the book, because the path to my project contained whitespaces.
Further information on the issue can be found here ( see Issue 696 on foreman@GitHub ), as other people have encountered the same issues (not specifically in the context of the book).

Apparently ‘foreman’ has to be installed directly via ‘gem install foreman’ (as described in the README for forman@GitHub )

235ERROR

First div tag in ‘TextFieldComponent/template.html’ I think there should be:

instead:

has-warning class is currently applied to the valid model, hence all fields are highlighted yellow.

128TYPO

Second, we’ll need test customers in our database tos earch for., should be Second, we’ll need test customers in our database to search for.

72SUGGEST

If I take the steps described in this book, the version of the Angular installed is v6.x series. Since there are incompatibilities exists (such as lack of Class function), the example does not work. If I install v4.x series (as the provided source code does), it works. Maybe need to include steps to force using v4.x.

Also, on MacOS X environment, current downloadable source, i.e., 6_angular/20-angularized-search don’t build.

hope this helps.

Ch. 6SUGGEST

PROBLEM: Following the procedure from chapter 6.0. Hello Angular example gives errors: “Can’t resolve ‘core-js/es7/reflect’ in polyfills.ts” and “Can’t resolve ‘core-js/es7/reflect’ in polyfills.ts”.
CONFIGURATION: Working through examples on Windows 10, Rails 5.2.3, webpacker 4.0.7, angular 8.2.0 installed by webpacker following the book instructions.
MY RESOLUTION:
Correction of polyfills.ts source:
-import ‘core-js/es7/reflect’;
+import ‘core-js/proposals/reflect-metadata’;
-import ‘core-js/es6/reflect’;
+import ’core-js/es/reflect;

This is a version conflict, I have experienced. For a novice like me it is easier to follow the book activities with default, fresh versions of components then enforcing previous versions that book assumes.
The web search reveals that “es7”, “es6” references are appropriate for core-js@2 module and webpacker installs core-js@3.
I’m submitting that for accumulation of version-related problems KB

13xiiiTYPO

First sentence of the second paragraph contains this fragment: “and Angular (or just Angular)”

Categories: