The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

In the authenticate middleware in the usersController, the if condition throws an error if the email address typed in does not match any user email address in the database. For it to work, the condition should change to this:
if (user && user.password === req.body.password)
Below Table 17.2--Data relationship, where the relationship between two models are described, the type definition is incorrect. The bold text in the part of the sentence below

... associated model's name where the type is Schema.Types.ObjectId

has to be


The two pages following this also have this typo.
Row 2 of the table has a typo. The second sentence should read:

Running Subscriber.findOne(...)
In the listing the error variable names do not match. The code
if ( error) throw err

has to be
if ( error) throw error

err has to change to error
Version 4.16.2 of Express used in the book has body parser built into it and is therefore not necessary to install it separately.

We can use it as follows:

app.use( express.urlencoded(...) )
app.use( express.json() )
The second paragraph of this section has a typo as follows:

<my-component v-bind:text="message"></my-message>

That should be

<my-component v-bind:text="message"></my-component>
Chapter 4's source code is missing from the Github repository. Other chapters' code missing as well.
It on page 68 of the pdf book of the MEAP v14.
The prop passed to the Button component
<Button submitTodo={this.submitTodo} />

throws an error. The correct value has to be
<Button submitTodo={() => this.submitTodo()} />
In this listing, below todoIndex++, you have
this.setState({todos: this.state.todos, inputValue: ''}, ...) 

I don't think mutating the state this way is a good practice. Instead, I suggest doing something like this:
const newTodos = this.state.todos.concat(todo)
this.setState({ todos: newTodos, inputValue: ''}, ...)
This issue was first raised in April 2017 and you responded to it in June 2017. Six months was enough time for you to have updated the book to use react-router v4. I don't think your explanation here is acceptable. The reality is that you just don't want to update the book.
Chapters 6 and 7 are not new; they were released in the previous MEAP.
The correct command is "ng g c shipping -m shipping/shipping.module"
It's in the book.
In Listing 6.9, immediately after
exec ((err, location)...
the keywords json and status have been interchanged.
Chapter 6 makes reference to sendJsonResponse supposedly defined in an earlier chapter, but there is no such definition prior to its use.
In the TaskList component definition, the code snippet

{ => (
  return <Task key={} task={task} />

throws an error due to the explicit use of the return keyword together with the parenthesis (). The return keyword has to be removed.
The following statement in the section "With the v-if and v-else directives, Vue adds display: none to one of the buttons (the false condition), and removed it from the other (the true condition)."

The above sentence is true of v-show and not of v-if.
In the section of the MEAP v.2, the statement 'Adding it to our existing button will result in the button being removed from the DOM'. This statement is false. On the next page, the behavior of v-show is correctly described. So this statement has to change.
Thanks very much for your explanation.
Thanks for your response. The actual path I found is contacts-app-starter/src/app/+contacts/shared/models/
Can you show the structure of your project directory and the contents of your js folder?
In the second paragraph of this section, the reader is asked to navigate to contacts-app-starter/src/app/shared/models/. However, the 'shared' folder is empty.
I have just taken a cursory glance through the book, and I have seen that in the first four chapters, React.createClass is used, a construct which is deprecated. Could the author explain why he chose to use constructs that are deprecated? Is he going to update the book to remove all the deprecated materials?
It's surprising that some authors don't respond to readers' questions/comments and the editors don't do that either. The purpose of the MEAP is defeated if authors and editors ignore reader feedback.
Three different names have been used in Chapter 3. When defining the list item functional component, the name used is ListItemFunctional. When using it in the List component, it is referred to as Item, and in the last but one paragraph of section 3.4 when discussing the component 'key' it is referred to as List Item. The same name has to be used.
I'm wondering whether the author monitors this forum. The last time he responded to a reader was September 21. Manning, what's going on?
Immediately after creating the manage component, the reader is asked to update src/index.html. The file should rather be src/app/app.component.html
Thanks very much.
The DashboardComponent class' ngOnInit() and ngOnDestroy() methods both use
is not defined prior to its use. This throws the error message
Property 'subscription' does not exist on type 'DashboardComponent'
Just before the code listing to demonstrate the use of ComponentDidMount you have this statement:

"You get the previous state and previous props as arguments"

In the code, however, you have "nextProp" and "nextState" as arguments instead.
Hi Steve,

A few weeks ago you tweeted about you doing your second revision of the book, which suggests that you are done updating the whole book. If that is so why do we have only chapters 1 to 9 released?

The very slow MEAP release rate makes reading the book uninteresting.
My previous post was not quite right. Here is the tweet I referred to:

Okay!!!!!! Rails 4 in Action has gotten its last major revision!

In September he was still writing the book but now he's done with it.
On Page 171 of the pdf book (v11), the signing_up_spec does not have any reference to the name attribute but on page 174 the view (_form.html.erb) has the :name field. Since the user name is used for signing in, it should be in the spec.

Secondly, since the user name is used for signing in, it should be tested for uniqueness, which is not the case now.

On page 184 the following snippet of the creating_tickets_spec:

within "#ticket #author" do
expect(page).to have_content("Created by")

uses the email

but page 187 has This inconsistency has to be addressed.
As Listing 6.1 stands, it is not DRY.

The lines:

click_link "New Ticket"

are repeated. Way back in May I proposed a solution to this. See this link:

and I believe it is a neat trick to use to avoid repetition. Though the text has changed since then but the suggestion is still relevant.
The second p tag of Listing 3.16 app/views/projects/new.html.erb on Page 87 is missing the closing tag

Also, the text below Listing 3.19 spec/features/creating_projects_spec.rb
makes reference to Capybara's find method, but there is no find method used. However, the error message below it shows the use of the find method.
Take note that the above changed from:

Bundler.require(*Rails.groups(assets: %w(development test)))


Bundler.require(:default, Rails.env)

So the sentences on page 62 under "Applicaton configuration" that discuss this have to change.
I agree with you that the two should be separated to avoid such problems.
I don't think you have to apologize for anything. Maybe it was rude I pointed it out to you, in which case I owe you an apology.

The trouble is that since that was pointed out there has been another release (vsmilie of the book, but the error remained. For some reason whatever Manning does with the script before releasing it sometimes messes things up. For instance, there were sections of the text that appeared in v7 but disappeared from v8, but the author did not revise those sections. Inexplicable! Personally, I don't revisit sections I have dealt with already when new versions are released, but occasionally people point out errors I have already pointed out.

Also, since the author does not have a pdf copy of the book, when we don't give him enough information for him to get to the error we are referring to, it is easy for him to miss it.
Then this has to be corrected in the book.
I can still access the assets after moving them from the public folder to the files folder. I am now developing on Windows 7 so I am not sure it is operating system related.

Secondly, if the prefix of "Rails.root" is tucked in front of the path in the method store_dir, the file path becomes something like file:///c: ..., but without it, I get localhost:3000/files/...
Fair enough. I thought you asked for help to solve the problem. My code may not be elegant but it works for me. The code in the book does not work, so you'll have to wait for the author's solution in version 9.
For you to be able to solve this problem, you have to understand what is happening. When the user is not signed in, and he tried to create a new ticket he is redirected to the sign in page. When he successfully signs in, he is redirected to the home page and he will not see the "New ticket" link.

For the user to see that link, when he is redirected, where he wanted to go has to be saved, and he session is a good place to save it. When he successfully signs in, you can check to see if you have a value associated with that session key. If there is, redirect to that page. I showed my solution in the link I gave earlier. So you have to make changes in the Application controller and the ticket controller for this to work. If you still cannot get it to work I will repost my solution.
I am almost through with all 9 chapters updated by the author and I have posted the errors I encountered on this forum. All the changes required for the code to work are in some threads. here. I think I grouped my corrections by chapter.
What errors are you referring to? Be specific about the errors and the page numbers where you are encountering the problems.
Factory not registered: ticket suggests that you have not defined the ticket factory. Define it like so:

FactoryGirl.define do
factory :ticket do
title "Example ticket"
description "An example ticket, nothing more"
The reason is that it has been pointed out earlier and the author has already corrected it. Maybe check the forum posts since the last version release to make sure that the issue has not been addressed already.
> Oh? Did you take the gems out of your Gemfile?

i have not as yet done that. I will do that and, if the problems are not resolved, I will post to Stack Overflow.
There are a number of issues with my ticketee project. In the first place, .scss and .coffee files are not created. Also, I am getting some error messages that others are not getting. I cloned Steve's project and ran the specs and they pass while mine fail.

I copied one of Steve's passing feature files into my project and it failed. I then copied one of my failing features into the cloned project and it passed. So I can therefore conclude that there is something wrong with my project, but I can't figure out what it is. Has anybody got an idea of what might be wrong with my project? I am stuck on these errors and cannot proceed further.

I am using ruby 2.0.0-p195 and rails 4.0.0.
The code in your github repository does not pass. It fails with syntax errors. Here is my code that passes:

It was written while running rc1.
Add the following below 'name: "steve",' line:
email: "",
Can you give the url to the code again?
Answer to Question 1:
That line is there to ensure that if you are viewing the listing of tickets for a project, you don't see the listing of tickets for another project.

Answer to Question 2:
The '#' in #<%= %> is not a comment but a literal '#'. Remember that we are in the view and therefore a comment in it will be an html comment (<!-- ... -->smilie. So that snippet will appear as:
#1, #2, #3, etc.

Within erb tags, comments look like these:
<%#= ... %>
<%# ... %>

Message was edited by:
Why are you still using v7? v8 is out already and some of the errors pointed out may have been fixed in v8. I have not compared them though.
I am using Ruby version 2.0.0p0.

I switched to 1.9.3 and created a new gemset and installed rails 4.0.0.rc1. When I ran the spec, I got the same error message. I then upgraded rails to 4.0.0.rc2 and ran the spec, and the result was not different.

Message was edited by:
The above scenario does not pass as the book says. It fails with the message:

TypeError: can't cast ActionDispatch::Http::UploadedFile to string: INSERT INTO "assets" ("asset", "created_at", "ticket_id", "updated_at") VALUES (?, ?, ?, ?)

The parameter set passed by the browser to the controller is:

"ticket"=>{"title"=>"Carrierwave Upload",
"description"=>"Testing Upload Using Carrierwave",
"assets_attributes"=>{"0"=>{"asset"=>#<ActionDispatch::Http::UploadedFile:0x007fa3b51ae9c8 @tempfile=#<Tempfile:/var/folders/g0/dbsl971x63zgsq1qc0g8_nxh0000gn/T/RackMultipart20130618-3752-416xym>,
@original_filename="Photo on 12-06-24 at 8.04 PM.jpg",
@headers="Content-Disposition: form-data; name="ticket[assets_attributes][0][asset]"; filename="Photo on 12-06-24 at 8.04 PM.jpg"
Content-Type: image/jpeg
"commit"=>"Create Ticket",
You are right! Indeed on page 342 of v8 of the book, this can be seen there.
On pages 255, 259 and 265, change all occurrences of find_project to set_project

On page 262 what has to be removed is not correct. The before block after the removal should look like this:

before do
project = FactoryGirl.create(:project, name: "Internet Explorer")
define_permission!(user, "view", project)
define_permission!(user, "create tickets", project)

visit '/'
click_link 'New Ticket'

within("h2") { expect(page).to have_content("New Ticket") }

The third sentence of section 8.3.3 has this:
" ... the one inside features/viewing_projects.feature"

On page 267, the scope definition should change from:
scope :self_for, ...
scope :for, ...

Listing 8.6 spec/controllers/tickets_controller_spec.rb before block's first line should change from
sign_in(:user, user)

On page 276 change all occurrences of the following:
authenticate_users! --> require_signin!
find_project --> set_project
find_ticket --> set_ticket

On page 288 change the following:
<%= authorized?( ... <br /> to
<% authorized?( ... <br />
The scenario on Page 289, "Edit ticket link is shown to a user with permission" fails with the message "Unable to find link 'Example ticket'"

This statement on page 306 is making reference to Device and has to be changed:
The routing helper destroy_user_session_path is provided for free by Devise, ...

Page 307, Section 8.9.2 has cucumber file name for a feature:

Listing 8.18 on page 314 has the wrong admin email address. It has to be

On page 315 the email address in the statement:
Sign in as the admin user using the email of ""
has to change to
There are still some errors in previous chapters I pointed out in my earlier postings and are not repeated here.

The following are the errors/typos picked up in this chapter:

The second paragraph of Section 7.1 has this sentence:
"This line is uses a admin_user factory ..."

The sentence immediately following Listing 7.1 reads as follows:
"Here you use set up a user ..."

The second sentence after listing 7.2 uses before_filter and not before_action

The second sentence in the second paragraph after Listing 7.3 reads:
"... and you use all of them them further ..."

The text after Listing 7.10 on pages 217 and 218 use before_filter

The second sentence of the second paragraph of Section 7.5 uses the wrong spec path:

The signing_up_spec and creating_user_spec make use of the user email, but the sign_in_spec uses the user name, which is impossible to do. Having gone through the first 8 chapters of the book, it appears to me that the user name is not needed in the application, and therefore the sign_in spec has to be changed to use the user email.

Section 7.5.4, the user_params definition should change from
params.require(:user).permit(:name, :password, :password_confirmation)


params.require(:user).permit(:name, :email, :password, :password_confirmation)

The third paragraph of page 227 states:
"With all the steps implemented, both scenarios …"
There is only one scenario and not two.

Page 230 first line makes reference to attr_accessible

Listing 7.18 app/controllers/admin/users_controller.rb still uses update_attributes
The "Creating a ticket" scenario's last expectation has to be something like this:

within "#ticket #author" do
expect(page).to have_content("Created by #{}")

In that case we should have a statement like the following before the before block:

let(:user) { FactoryGirl.create(:user) }

The sentence immediately after
<span id='author'>Created by <%= %></span>

on Page 189 has to be fixed:

This small change will should make the feature pass now,...
Here you go:

Yours is passing because it is different from what is in the book.

Message was edited by:
If you follow the logic of the before block, it should not pass, because when a user logs in, he is redirected to the home page. And we don't have the "New Ticket" header on the Project#index page but rather on the Ticket#new page. That's the heading of that page.
The line:

within("h2") { expect(page).to have_content("New Ticket") }

is failing for this reason:
When the user is not logged in and clicks on the "New Ticket" link, he is redirected to the sign in page. After a successful sign in, he is redirected to the home page. The solution is to store the request.fullpath in a session and, after a successful log in, redirected to the path stored in the session (i.e. "New Ticket" page). It should look something like this in the ApplicationController:

def require_signin!
if current_user.nil?
session[:intended_destination] = request.fullpath
flash[:alert] = "You need to sign in or sign up before continuing."
redirect_to signin_url

So, the test should be modified to reflect this. Otherwise, the two statements

click_link 'New Ticket'

have to be added before "within("h2") ...", which is not DRY.

Also, there is no way of logging out.
This is what I did to the SessionsController's create action for the feature to pass:

def create
user = User.where(:name => params[:signin][:name]).first
if user && user.authenticate(params[:signin][:password])
session[:user_id] =
flash[:notice] = "Signed in successfully."
if session[:intended_destination]
redirect_to session[:intended_destination]
redirect_to root_url

flash[:alert] = "Sign in failed."
render :new
The flash statement for failed sign in should be flash[:alert] = "Sorry." because there is no id called error in the "application" stylesheet file.
The above route definition fails with the following error:

Invalid route name, already in use: 'signin'
You may have defined two routes with the same name using the `:as` option, ...

Is it also an rc1 issue?
Here you go:

root :to => "projects#index"

resources :projects do
resources :tickets

resources :users

get "/signin", to: "sessions#new", as: "signin"
post "/signin", to: "sessions#create", as: "signin"
The sign up feature only uses "Email" and not "Username", but the view has both fields. When signing in however, the "Email" field is not used in the view but the "Username" is. This suggests that the "Username" field is a required field and has to be added to the Signing up scenario.

Also, the user_profile feature has the following scenario heading:
"Scenario: Updating a project" instead of "Scenario: Updating a user
The bold portion of this example is failing:

it "needs a password and confirmation to save" do
u = "steve")
expect(u).to_not be_valid

u.password = "password"
u.password_confirmation = ""
expect(u).to_not be_valid

u.password_confirmation = "password"
expect(u).to be_valid
The authentication examples' expectation statements should use authenticate and not authentication i.e. user.authenticate(...)

Also, those 2 statements are not complete. They should read .to be_valid and to_not be_true respectively.

password_confirmation appears to be irrelevant now. Is it a new feature or a bug? Only passord is required for the password digest to be created, and for this reason the first example does not pass.
Yes, the MEAP v7.
I think it is an issue with rc1 because with password_confirmation set to "", it still creates the password digest as can be seen below:

uu = User.create!(name: "Emmanuel", password: "password", password_confirmation: "")
(0.1ms) begin transaction
Binary data inserted for `string` type on column `password_digest`
SQL (0.4ms) INSERT INTO "users" ("created_at", "name", "password_digest", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Mon, 20 May 2013 18:01:43 UTC +00:00], ["name", "Emmanuel"], ["password_digest", "$2a$10$I4VrGzFOmG1p3Oi61NWAguEPNFpaYCgbVQHSJ/a853O9cThKRDab."], ["updated_at", Mon, 20 May 2013 18:01:43 UTC +00:00]]
(5.9ms) commit transaction
=> #<User id: 3, name: "Emmanuel", email: nil, password_digest: "$2a$10$I4VrGzFOmG1p3Oi61NWAguEPNFpaYCgbVQHSJ/a853O9...", created_at: "2013-05-20 18:01:43", updated_at: "2013-05-20 18:01:43">
Rails 4.0.0.rc1
In the rails console, once a name and password are supplied and the password confirmation is set to blank,and the user object saved, the password digest is generated.

I used the rails console because I couldn't get the test to pass and I was wondering what was happening. Even when the test runs in the CLI, you can see the password digest created which causes the test to fail.

Go to the rails console and do the following to see what the problem is:
u = User.create!(name: "Steve", password: "password")

You will see that the password_digest is created.
I am using rails version 4.0.0.rc1 and it has a different syntax for the index. It looks like this:
t.references :project, index: true

If your version creates this line, then you do not have to add this line:
add_index :tickets, :project_id
After the definition of the index action, the text states
... you can run the feature with bin/rspec spec/features/creating_projects_spec.rb instead of ... viewing_projects_spec.rb
The following Listings and Figures have the Listing x.y and Figure x.y repeated:
Page 136, Figure 5.1
Page 153, Listing 5.7
Page 154, Listing 5.8
Page 161, Listing 5.10
Page 164, Listing 5.12

Also, on Page 157, the statement that reads "we're writing feature tests write now" should change to "we're writing feature tests right now"

On Page 160 Section 5.3.1, change find_ticket to set_ticket
There is no consistency between Listing 4.8 and Listing 4.11: update vs update_attributes

On page 130, section 4.4.2 the an in "rather than an feature test" should be changed to a.

On page 132 just below Listing 4.15, the statement "use the before_filter method" is making reference to before_filter and not before_action.
On page 70 there is a type in the sentence that reads: This error is happening becuase ...

On page 81 the sentence: One common bit of logic is the way your application to interacts with
has to be fixed.
In section 3.1.1 the statement:
page.should have_content("You have been successfully logged in.")
should be changed to:
expect(page).to have_content("You have been successfully logged in.")
On the bottom of page 414, the continuation of the sentence "The find_by_default method here is a dynamic finder method from" is missing. It looks like a number of sentences or paragraphs are missing.

Sections 10.8.1 and 10.8.2 are also missing some text.

Message was edited by:
This scenario is missing this first step:
click_link ticket.title
When I click on a ticket to be edited, the text fields for the title and description are filled with the text for these two. However, the file fields are not populated with the names of the filed previously attached to the ticket. Why is that?

Also, I cannot get the "Creating a ticket with an attachment" using javascript scenario to pass. What I find strange is the fact that in the browser, I am able to attach multiple files to a ticket and save the ticket. The example always fails with this error message: cannot attach file, no file field with id, name, or label 'File #2' found. Has anybody managed to get this scenario to pass and would like to share his/her code?
The statement:
let(:ticket) { Factory(:ticket, :project => project, :user => user) }
has an undefined user variable. I think user should be good_user.
The command for running the first feature of Chapter 9 uses the following:
bin/cucumber features/creating_tickets.feature
instead of:
rspec spec/integration/creating_tickets_spec.rb
There are two typos on page 316:
In listing 8.19 the last statement has unnecessary brackets on the end (]]>smilie. Further down the page, there is this statement:
Sign in as the admin user using the email of "".
The admin email address should be "" and not ""
The sentence immediately following the definition of "authorized?" has a typo error. It reads "This helper uses CanCan’s can? method to check if the user is authorization to perform this action." The "is" has to be "has"
There is an omission in the sentence "Let’s this restriction next". It should be something like "Let's deal with this restriction next."
Under Scenario "Listing all projects", there is an error in this line:
click_link project.title
It should be
That is correct; that code is missing from the current and the previous pdf versions.
The explanation of csrf_meta_tag is not complete. The sentence in question is This unique token works by ...
There is a typo in this sentence:
By requiring the lib/bacon.rb file we the Bacon constant is defined.

we has to be deleted.
There is a typo in this sentence:
In order to do this though, we must have two three things installed:
Hi Ryan,

I cannot figure out an easier way to add the first admin user to the system other than first creating a non-admin user, going into the database and changing the boolean field "admin" to true. This implies that the system must have a default admin user and password when it is deployed.

Am I missing anything obvious?

This approach is much easier and cleaner. Thanks a lot.