Susan Harkins (203) [Avatar] Offline
#1
Please post errors you find in the published version of Rails 4 in Action here. We'll compile and publish a comprehensive list for everyone's convenience. Thank you!

Susan Harkins
Errata Editor
320708 (1) [Avatar] Offline
#2
Hello smilie

page 164, half way down, "...will try to apply a foreign key on your tickets table, pointing to an authors table - and you don't have a ticket table." shouldn't it be "... - and you don't have an author table."?
joeradtke (2) [Avatar] Offline
#3
p. 137. The within has an argument of "#ticket h2"; there is no such selector on the projects/show view. It probably should be "tickets" although that doesn't work either. (produces an error that it can't find the css)
illusionld (4) [Avatar] Offline
#4
pg. 165
$bundle exec rspec spec/features/creating_tickets_spec.rb

results in:
...
undefined method `email' for nil:NilClass
...


but adding the following to the create action of the TicketsController doesn't fix the failed test:
@ticket.author = current_user


although at the bottom of pg.165 the book shows that the test passes. Page 166 adds some CSS to the stylesheets which shouldn't "break some of the features" as stated at the top of pg. 167 when the same test is rerun.

The test will pass only after fixing the code as in 6.4.1 Fixing the failing four features.

You also have to sign in and create a new ticket under a project when viewing through a browser or you'll receive: undefined method `email' for nil:NilClass since the old tickets were created without an associated user.
dsmnd (2) [Avatar] Offline
#5
On page 207 of the published version [paperback], there is the following line:

$ bundle exec rspec spec/features/admin/deleting_users_spec.rb



The line should be testing the feature for archiving users and should instead read:

$ bundle exec rspec spec/features/admin/archiving_users_spec.rb


This line (the correction) was first mentioned on page 205 in section 7.4.7 "Archiving users".

On page 213, listing 7.6.7 provides the following YAML file:

config/locals/devise.en.yml


The actual location is in the following directory:

  • config/locales



  • dsmnd (2) [Avatar] Offline
    #6
    On page 305, there's a missing 'end' for the "managers of other projects" context.

    context "for managers of other projects" do
      before do
          assign_role!(user, :manager, FactoryGirl.create(:project))
      end
      it { should_not permit_action :show }
    # no end in sight
    

    387555 (1) [Avatar] Offline
    #7
    In section 5.1.4 you add a
    has_many :tickets
    relation on the ]Project model. But you also need a
    belongs_to :project
    relation on the Ticket model; otherwise the FactoryGirl.create(:ticket) call in the spec in listing 5.9 breaks.

    Forgive me if this association is already in the text and I overlooked it.
    sevenseacat (40) [Avatar] Offline
    #8
    320708 wrote:Hello smilie

    page 164, half way down, "...will try to apply a foreign key on your tickets table, pointing to an authors table - and you don't have a ticket table." shouldn't it be "... - and you don't have an author table."?


    Confirming that this should indeed say `authors`, not `ticket`.

    joeradtke wrote:p. 137. The within has an argument of "#ticket h2"; there is no such selector on the projects/show view. It probably should be "tickets" although that doesn't work either. (produces an error that it can't find the css)


    This is not an issue - the spec is looking on the tickets/show template, not projects/show (the previous line of the spec clicks on the ticket name to go to the tickets show page).

    illusionld wrote:pg. 165
    $bundle exec rspec spec/features/creating_tickets_spec.rb
    

    results in:
    ...
    undefined method `email' for nil:NilClass
    ...


    but adding the following to the create action of the TicketsController doesn't fix the failed test:
    @ticket.author = current_user


    although at the bottom of pg.165 the book shows that the test passes. Page 166 adds some CSS to the stylesheets which shouldn't "break some of the features" as stated at the top of pg. 167 when the same test is rerun.

    The test will pass only after fixing the code as in 6.4.1 Fixing the failing four features.

    You also have to sign in and create a new ticket under a project when viewing through a browser or you'll receive: undefined method `email' for nil:NilClass since the old tickets were created without an associated user.


    This seems to be talking about a lot of different issues, none of which I can replicate. Can you provide some more information?

    dsmnd wrote:On page 207 of the published version [paperback], there is the following line:

    $ bundle exec rspec spec/features/admin/deleting_users_spec.rb



    The line should be testing the feature for archiving users and should instead read:

    $ bundle exec rspec spec/features/admin/archiving_users_spec.rb


    This line (the correction) was first mentioned on page 205 in section 7.4.7 "Archiving users".

    On page 213, listing 7.6.7 provides the following YAML file:

    config/locals/devise.en.yml


    The actual location is in the following directory:

    config/locales


    Yes, `spec/features/admin/deleting_users_spec.rb` should be `spec/features/admin/archiving_users_spec.rb`, and `config/locals` should be `config/locales`. Yay for proofreading! Sorry about that!

    dsmnd wrote:On page 305, there's a missing 'end' for the "managers of other projects" context.

    context "for managers of other projects" do
      before do
          assign_role!(user, :manager, FactoryGirl.create(:project))
      end
      it { should_not permit_action :show }
    # no end in sight
    



    Yes, you are quite correct. In my defence, the code examples on GitHub do have the missing `end` so I'm not sure where it went in the book!
    https://github.com/rubysherpas/r4ia_examples/blob/master/ticketee/spec/policies/attachment_policy_spec.rb

    387555 wrote:In section 5.1.4 you add a
    has_many :tickets
    relation on the ]Project model. But you also need a
    belongs_to :project
    relation on the Ticket model; otherwise the FactoryGirl.create(:ticket) call in the spec in listing 5.9 breaks.

    Forgive me if this association is already in the text and I overlooked it.


    This is added when you generate the Ticket model in section 5.1.5 - running `rails g model ticket name:string description:text project:references` will add the correct association from Ticket to Project.

    ----

    Also valid errata:
    https://forums.manning.com/posts/list/35942.page#p104603

    The fix here:
    https://forums.manning.com/posts/list/35942.page#p104680

    Should be made to listing 8.80, on page 275.
    402089 (2) [Avatar] Offline
    #9
    The link on page 28 - Another great example of rapid development of a Rails application is the 20-minute blog screencast recorded by Yehuda Katz (http://vimeo.com/10732081). - does not work.
    402225 (3) [Avatar] Offline
    #10
    Listing 8.83 on page 279.

    The line
    role_data = params.fetch(:roles, [])

    should be
    role_data = params.fetch(:role, [])
    402225 (3) [Avatar] Offline
    #11
    402225 wrote:Listings 8.83 on page 279 and 8.87 on page 281.

    The line
    role_data = params.fetch(:roles, [])

    should be
    role_data = params.fetch(:role, [])
    402225 (3) [Avatar] Offline
    #12
    The bundle exec rspec spef/features/creating_tickets_spec.rb just after Listing 11.8 on page 390 says
    7 examples, 0 failures
    I think it should be
    6 examples, 0 failures
    437034 (1) [Avatar] Offline
    #13
    Hello,

    First of all: I want to say this book is absolutely amazing, and I am very lucky to be reading it.

    I ran into an issue on Chapter 13 around page 457 for when it was time to push the code up to heroku:

    git push heroku master


    It just would not work for me, and after about 6 hours of searching online and trying everything, I finally got it. I had to update the fog gem to version 1.38.0. The book has the reader use the version 1.29.0. I got the hint of changing the fog version on this page:

    https://github.com/fog/fog/issues/3765

    For what it is worth: I did post a stack overflow question about this which goes into more detail about the error I was getting, as well as what I did to fix the error:

    http://stackoverflow.com/questions/40625161/rails-4-in-action-unable-to-push-code-to-heroku-sh-2-syntax-error-untermina