Errata

Rails: Up and Running

Errata for Rails: Up and Running

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
Printed Page ix
1st paragraph

error generated: NameError (uninitialized constant ApplicationController):

Since the introduction of Rails 2.3 the application.rb file has been renamed to application_controller.rb.
So in order to solve the problem just rename your file application.rb to application_controller.rb.

Thanks to http://www.hackido.com/2009/03/quick-tip-solve-uninitialized-constant.html

Anonymous  Oct 29, 2009 
Printed Page 2
2

stale links in two locations on this page
http://wiki.rubyonrails.org/rails/pages/GettingStartedWithRails should be http://wiki.rubyonrails.org/start
http://wiki.rubyonrails.com/rails/pages/HowtoUseSQLite should be http://wiki.rubyonrails.org/database-support/sqlite

Patrick MacLachlan  May 16, 2009 
2.1
Figure 2.1

Photos and slides are a one-to-one relationship, but the figure shows slides to photos as one to many.

Kathy Jacobson  May 20, 2009 
2.2
Second code sample, for config/database.yml

The test database should be photos_test, not photos_development.

Kathy Jacobson  May 20, 2009 
2.3.1
3rd paragraph

"Rails generated a bunch of files, including a controller and a a few views, ..."

Should be, "... and a few views, ..."

Kathy Jacobson  May 20, 2009 
2.3.1
4th paragraph

"Rails will use these timestamps to help you apply incremental changes to your database schema you need them, ..."

Is there a missing "as" between "schema you"?

Kathy Jacobson  May 20, 2009 
2.4.2
the script/console code

Creating a new slide is not working for me. I did put in the skip_before_filter. All other aspects of this exercise are working, as far as I can tell.

I am using Rails 2.3.2.

>> app.post "/slides", :slide=> {:position=>10, :photo_id=>1, :slideshow_id=>1}
=> 302
>> app.response.body
=> "<html><body>You are being <a href=\"http://www.example.com/slides/996332881\">redirected</a>.</body></html>"
>> app.request.path_parameters
=> {"action"=>"create", "controller"=>"slides"}
>> app.get "/slides/10"
=> 404
>> app.response.body
=> "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>\n <title>Action Controller: Exception caught</title>\n
...
\n</head>\n<body>\n\n<h1>\n ActiveRecord::RecordNotFound\n \n in SlidesController#show\n \n</h1>\n<pre>Couldn't find Slide with ID=10</pre>\n\n\n\n<p>
...
>> app.delete "/slides/10"
=> 404
>> app.response.body
=> "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>\n <title>Action Controller: Exception caught</title>\n
...
\n</head>\n<body>\n\n<h1>\n ActiveRecord::RecordNotFound\n \n in SlidesController#destroy\n \n</h1>\n<pre>Couldn't find Slide with ID=10</pre>
...

Kathy Jacobson  May 20, 2009 
3.1.2
4th paragraph

The explanation of Photo Show in 2.1 said that photos could belong to one OR MORE categories, so why is it being set up as a many-to-one relationship?

Kathy Jacobson  May 20, 2009 
3.5.1
Figure 3.1

The contents of Figure 3.2 are actually what Figure 3.1 is supposed to have. Whatever is supposed to be in Figure 3.2 does not appear anywhere in the chapter, as far as I can tell.

Kathy Jacobson  May 21, 2009 
4.3
1st paragraph

"...you can implement one-to-one relationships with belongs_to or has_one."

This implies that you use one or the other macro. According to the API (http://apidock.com/rails/ActiveRecord/Associations/ClassMethods) you need to use both, and the issue is which one goes where. The answer (as the text correctly states) is, "The belongs_to association is always used in the model that has the foreign key."

Kathy Jacobson  May 22, 2009 
4.5
the last console code

reload! is insufficient to load the newly installed plugin, acts_as_list. I had to restart the script/console.

Kathy Jacobson  May 22, 2009 
5.2
?

If you are using Rails 2.3.2 (current as of this writing) and you use the downloaded example files, you will need to rename photos/app/controllers/application.rb to photos/app/controllers/application_controller.rb. Otherwise you receive an error message: uninitialized constant ApplicationController. This rename was not necessary in the chapters where we used just the console.

Kathy Jacobson  May 22, 2009 
5.4
Last paragraph

Since we have changed the routes.rb file, we'll need to restart the server in order for the changes to be picked up.

Kathy Jacobson  May 22, 2009 
5.5
code for app/views/layouts/application.html.erb

In the body, in the div, why leave the style info? I thought that is what we were moving to the stylesheet.

Kathy Jacobson  May 22, 2009 
6.2
last sentence

The code gives the user three options: Play, Edit, and Delete, so to show a slideshow, click Play, not show.

Kathy Jacobson  May 23, 2009 
6.2
last sentence

Session cookie overflow after only 4 pictures.

Processing SlideshowsController#show_slide (for 127.0.0.1 at 2009-05-23 15:58:35) [POST]
Parameters: {"authenticity_token"=>"U="}
Photo Load (0.7ms) SELECT * FROM "photos" WHERE ("photos"."id" = 4)
Rendered slideshows/_show_slide (13.3ms)
Completed in 44ms (View: 14, DB: 1) | 200 OK [http://localhost/slideshows/show_slide]


Processing SlideshowsController#show_slide (for 127.0.0.1 at 2009-05-23 15:58:37) [POST]
Parameters: {"authenticity_token"=>"U="}
Photo Load (0.7ms) SELECT * FROM "photos" WHERE ("photos"."id" = 5)
Rendered slideshows/_show_slide (11.3ms)
Completed in 40ms (View: 12, DB: 1) | 200 OK [http://localhost/slideshows/show_slide]
/!\ FAILSAFE /!\ Sat May 23 15:58:37 -0400 2009
Status: 500 Internal Server Error
ActionController::Session::CookieStore::CookieOverflow

Kathy Jacobson  May 23, 2009 
6.3
16rd paragraph

The code is like this

module SlideshowsHelper
def thumbnail_tag(slide)
image_tag("photos/#{slide.photo.thumbnail}",
:style=>"vertical-align:middle") if slide
:class => "photos") if slide
end
end

instead of

module SlideshowsHelper
def thumbnail_tag(slide)
image_tag ("photos/#{slide.photo.thumbnail}",
:style => "vertical-align:middle",
:class => "photos") if slide
end
end

Anonymous  Oct 06, 2008 
6.3
16rd paragraph

You have:

module SlideshowsHelper
def thumbnail_tag(slide)
image_tag("photos/#{slide.photo.thumbnail}",
:style=>"vertical-align:middle") if slide
:class => "photos") if slide
end
end

And it should be:

module SlideshowsHelper
def thumbnail_tag(slide)
image_tag(("photos/#{slide.photo.thumbnail}"),
:style => "vertical-align:middle",
:class => "photos") if slide
end
end


I send it a previous one, but i notice that i also made a mistake.

Anonymous  Oct 07, 2008 
6.3
first sentence

"The scaffolding we have for editing a slideshow shows just the slideshow attributes that are stored directly in the slideshows table: the slideshow's name and the creation date."

The creation date does not show on the slideshow page or on the editing page.

Kathy Jacobson  May 23, 2009 
6.4
30

In the book you have the following line:

Next, create a file called app/views/slideshows/remove_slides.rjs with the following contents:

But it cannot work because the reference file should be:

Next, create a file called app/views/slideshows/remove_slide.rjs with the following contents:

because the method in the controller is also remove_slide.

Anonymous  Oct 07, 2008 
6.4
explanation of the app/views/slideshows/edit.html.erb code

"the partial template photo_picker renders slideshow-photo-picker"

The "unused_photo" partial template renders slideshow-photo-picker, not photo_picker.

Kathy Jacobson  May 26, 2009 
6.4
explanation of add_photo method in app/controllers/slideshows_controller.rb

In the explanation of the new add_photo method in app/controllers/slideshows_controller.rb,

"slideshow_id = session[:slideshow].id"

This line of code does not appear in method given in the text, nor is it in the end-of-chapter example code.

Kathy Jacobson  May 26, 2009 
6.4
bottom of page (after entering code or even downloading code) if using Rails 2.3.4

Using Rails 2.3.4, the session variable is by default tracked with a cookie. It appears that assigning the session variable
session[:slideshow] = @slideshow = Slideshow.find(session[:slideshow].id)
breaks the cookie maximum 4KB.

This is manifested in an Internal Error page being displayed, and the error of
Status: 500 Internal Server Error
ActionController::Session::CookieStore::CookieOverflow
being displayed in the log or server console.

This is fixed by explicitly setting Rails to use Databased Sessions
Add
config.action_controller.session_store = :active_record_store
to the /config/environments/development.rb file (I added here. It may work in /config/environment.rb)

Then, you need to create the session table as below
rake db:sessions:create
rake db:migrate

Restart the server and it works.

Also, the slideshow itself was failing after 6 pictures had been displayed. It was fixed with this change in the session store also.

Alan Elliott  Oct 02, 2009 
7.3.1.2
paragraph below the box

"CSV files are useful when you have existing data in a database or spreadsheet that you can export to CSV format. CSV files are useful when you already have input data in that format."

These sentences are redundant. Pick one.

Kathy Jacobson  May 26, 2009 
7.3.1.3
various code samples

TestCase has been moved from Test::Unit::TestCase to ActiveSupport::TestCase in v. 2.3.2. Make this change in /test/test_helper.rb.

Kathy Jacobson  May 26, 2009 
7.3.1.1
Last paragraph

Even though I am using SQLite my test.sqlite db was empty until I did this (rake db:test:clone). That is, Rails did not "build the database structure before each test run" as the text stated. I am using Rails 2.3.2.

Kathy Jacobson  May 26, 2009 
Printed Page 10
Top of page

In order to print the has enabled by the mods in greeting_controller.rb, one has to create a database in their database application. If this is not done, the has will not be displayed. An error about being unable to get to a database will appear.

r3dshirt  Dec 24, 2008 
Printed Page 13
Line 10

There is a typo in some instruction on page 13 that make the instructions not work. On line 10, it states:

Point your browser to http://localhost:3000/greetings/index

It should read

Point your browser to http://localhost:3000/greeting/index


Anonymous  Nov 09, 2009 
Printed Page 14
3rd, 4th, 5th paragraphs

This section is describing the simple techniques of expressions and scriptlets. There are three sentences, each ending in a colon followed by a bit of code demonstrating one of the techniques.

The problem seems to be that the technique following the colon isn't what was described by the sentence. For example, here's the first sentence:

"Next, here's the view/index.html.erb view showing expressions and scriptlet, both of which interact with values set in the controller:

<h1>Simple expressions</h1>
<p>Tommy is <%= @age %> years old.</p>

Now, display the value..."

You'll note that in the code following that sentence, only one expression is present. No scriptlet. The next two sections on the page are also not describing the code.

Basically, the code is in order, but the text that describes the code is all jumbled up.

I'm 20 pages into this book, and I've found two language errors like this that have made it difficult to understand what the book's trying to teach me. I'm not a professional coder, so I always have to figure out if I just didn't understand the book or if the book is actually incorrect. In this case, I think the book's wrong, because the concept is simple enough for even me to understand.

John Nolt  Jan 02, 2010 
Printed Page 20
code snippet at top of page

In the code snippet at the top of the page, describing how to alter the yml file for MySQL, this appears:

test:
adapter: mysql
database: photos_development
username: root
password:
host: localhost

shouldn't "photos_development" be "photos_test"?

John Nolt  Jan 02, 2010 
Printed Page 25
Paragraph 4

I have Rails 2.2.2.
When click Create get ActionController::InvalidAuthenticityToken error.

This is because Rails 2.2.2 has forgery protection on.

I had to site wide disable by putting the following line in

self.allow_forgery_protection = false

in app/controllers/application.rb

The book needs to mention this and explain how to use forgery protection.

Solomon Hamid  Apr 29, 2009 
Printed Page 34
2nd paragraph and 3rd paragraph

the word "text" in the path text/fixtures... should be "test"

Dave  Nov 20, 2009 
Printed Page 34
2nd paragraph

In the sentences following there are two errors:

"As always, create the test fixtures with the data below. text/fixtures/slideshows.yml should like like the following: "

the word "text" in the path specified should be replaced by "test". The word "like" is repeated: the first "like" should be replaced by "look".

Thats it!

regards,

Duncan Smith

Duncan Smith  Mar 21, 2010 
Printed Page 48
Figure 3-1

The Figure 3-1 does not represent "Rails supports single-table inheritance between an entity (Person) and a subclass (Photographer".

Anonymous  Nov 01, 2008 
Printed Page 48
First paragraph below figure 3-1

The code:

class Photographer < Person
end

should be saved to a file named "photographer.rb" located in the ./photos/app/models/ folder. (You may need to create this file)

Anonymous  May 01, 2010 
Printed Page 48
First line of code below Fig 3-1

There is an instruction:

Now, we need classes, which are trivial:
class Photographer < Person
end


Which file is this meant to go in? I tried the Person model, but it came back with an error.

Anonymous  May 31, 2010 
Printed Page 50
Figure 3-2

The Figure 3-2 does not present what text supposed to explain.

Anonymous  Nov 01, 2008 
Printed Page 50
Figure 3-2

I believe under the Class: Photographer < Person portion of the diagram, type should be "Photographer".

Anonymous  Nov 20, 2008 
Printed Page 79
3rd paragraph

This page mentions a config/database.yml.example file that needs to be copied but this file cannogta be found anywhere in the zip file

Dave  Nov 20, 2009 
Printed Page 90
first paragraph

States "the code dealing with pagination...has been removed", I do not believe there was any pagination code in there to start. Also see the photos-after-chapter-4 under example code.

Unless the pagination change is automatic when we changed variable names around from categories to all_categories in the controller, but this is not obvious at all to a novice.

Anonymous  Nov 25, 2008 
Printed Page 105
2nd paragraph

<%= periodically_call_remote :update => "slides",
:url => { :action => :show_slide },
:frequency => 2.0 %><% end %>

fails with: syntax error, unexpected tASSOC, expecting ')'
:url=> { :action=> :show_slide}

fixed with:

<%= periodically_call_remote (:update => "slides",
:url => { :action => :show_slide },
:frequency => 2.0) %><% end %>

Running Rails v. 2.3.4 Mac Snow Leopard and PostgreSQL 8.3

Peter Ritchie  Oct 31, 2009 
Printed Page 105
2nd paragraph

The line for periodically_call_remote results in a routing error when using rails 3.

ActionController::RoutingError in Slideshows#show

No route matches {:action=>"show_slide", :controller=>"slideshows", :escape=>false}

Any help would be greatly appreciated.

Anonymous  Apr 16, 2011 
Printed Page 109
This exercise

My ajax calls to the server to sort the pictures fails, the error returned in the call is "Missing template slideshows/update_slide_order.js.erb in view path". I no not see a reason to create that file, no mention of it in the text. When I create an empty file with that location the example works fine. I could not see a reason for this error.

Windows xp / Rails 2.1.2 / Ruby 1.8.6

Anonymous  Nov 30, 2008 
Printed Page 110
code block

The ") if slide" conditional is repeated twice, looks like a syntax error and it causes my runtime to exception out

Anonymous  Nov 30, 2008 
Printed Page 110
1st code block

the code block is pretty messed up. It reads:

module SlideshowsHelper
def thumbnail_tag(slide)
image_tag("photos/#{slide.photo.thumbnail}",
:style=>"vertical-align:middle") if slide
:class => "photos") if slide
end
end

and should read:

module SlideshowsHelper
def thumbnail_tag(slide)
image_tag("photos/#{slide.photo.thumbnail}",
:style=>"vertical-align:middle",
:class => "photos") if slide
end
end

I got to do some error checking so I learned a bit of syntax in the process.

Dave Jezak  Nov 24, 2009 
Printed Page 111
Figure 6-3

It looks like fig 6-3 is an image of the application after more styling was added on pages 117-118.

Anonymous  Nov 30, 2008 
Printed Page 114
top line

The line states "notice...drop_receiving_element and observe_field", observe_field has yet to be added to anything, I think the first time it is shown is page 118.

Anonymous  Nov 30, 2008 
Printed Page 114
last bold line

It references the line @photos = unused_photos(@slideshow) the line is actually @photos = @slideshow.unused_photos

Anonymous  Dec 03, 2008 
Printed Page 115
1st line

def unused_photos(slideshow)

should be:

def unused_photos

to match the code on page 114 and the sample code

Dave Jezak  Nov 24, 2009 
Printed Page 131
Second bold line

You state at the start of this section: "Let's walk through the code a line at a time", then you reference "fixtures :photos", which is *not* in the above code we are walking through but added immediately following.

Lots of things like this throughout the book. If you say we are going through the code line by line, referencing lines we have yet to add gets very confusing!

Anonymous  Dec 03, 2008 
Printed Page 153
#2 in the list of steps

One of my clients is reading the book to learn rails and found a bug
in the sqlite installation process. It says to unzip the file into
C:\WINDOWS\system. These instructions work fine in Windows XP, but my
client is using Windows Vista. In order to get this to work in Windows
Vista, we had to copy the file into C:\Windows\System32 instead. Not
sure what the easiest way to format that is in the book, but we should
keep this in mind.

Anonymous  Oct 20, 2008 
Printed Page 153
Line item #2

"...file to C:\Windows\system." should say "...file to C:\Windows\system32."

David Corey  Aug 04, 2009 
Printed Page 153
Line items 2 & 4

The instructions will not result in the successful installation of SQLite.

Use the following:

At a minimum, you need to download two Windows binaries:
sqlite-3_6_16.zip and sqlitedll-3_6_16.zip
Extract the contents of these 2 zip files copying:
sqlite3.exe to C:\Windows\System32
sqlite3.def and sqlite3.dll to C:\Ruby\bin

Instead of the gem install command specified, use the following:
gem install sqlite3-ruby --source http://gems.rubyinstaller.org

David Corey  Aug 05, 2009