Errata


Print Print Icon

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



Version Location Description Submitted By
Safari Books Online 9.3
9.3.2. Changing the controller (Nesting awards in students)

After modifying the controller and the view code the new function get_student fails because it doesn't get the student ID

Below is the error code generated by the Mongrel server

Processing AwardsController#index (for 127.0.0.1 at 2009-09-18 12:24:42) [GET]

ActiveRecord::RecordNotFound (Couldn't find Student without an ID):
app/controllers/awards_controller.rb:96:in `get_student'

Rendered rescues/_trace (188.0ms)
Rendered rescues/_request_and_response (0.0ms)
Rendering rescues/layout (not_found)


Below the rails environment

Ruby version 1.8.6 (i386-mswin32)
RubyGems version 1.3.5
Rack version 1.0
Rails version 2.3.3
Active Record version 2.3.3
Action Pack version 2.3.3
Active Resource version 2.3.3
Action Mailer version 2.3.3
Active Support version 2.3.3
Application root C:/Documents and Settings/SSanjuan/Mis documentos/Ruby/Rails/students
Environment development
Database adapter mysql
Database schema version 20090918095050

Thanks

Salvador 
PDF Page 165
After the second paragraph past the first block of code

I'm having problems with the course_remove method. When I go to remove a course from a student (example: http://localhost:3000/students/3/course_remove) after pressing the "Remove checked courses" button, I get this error:

Unknown action

No action responded to course_remove. Actions: course_add, courses, create, destroy, edit, index, name, new, show, and update

I've done quite a bit of checking, but I can't figure out what I'm doing wrong. Any ideas? Other than that, the application seems to be working fine.

Eric Gruber 
Printed Page 273
16.3.1 - Making the Form More Scriptable

(this applies to both the online and print edition).


Under Example 16-1, the code:

:html => {:id =>
'enrollment_form'}

Needs to between the first and second parenthensis, so that instead of:

<% form_tag(course_remove_student_path(@student)), :html => {:id =>
'removal_form'} do %>

It will be:

<% form_tag(course_add_student_path(@student), :html => {:id =>
'enrollment_form'}) do :%>

The change will have to be made on the "course_remove_student_path" and "course_add_student_path" - otherwise, it'll crash.

Also, this:

<table id="CoursesEnrolled">

Needs to bolded.

On another note, the paragraph before example 16-2 was incorrect. Besides changing:

"Course.find(params[:course]"

to

"course_ids = params[:courses]"

you also have to create a

"course_ids.each do |course_id|"
*stuff*
end

block and then put the existing "unless @student.enrolled_in?(course)" block within it. That was in the source coded in the example, but the paragraph didn't explain that you need to do that.

Rilindo Foster 
Safari Books Online 295
Example 17-10

Its also in the Online and likely PDF version.

Found two issues.

The first issue is that, if you install Inline Attachments (which is now called something else) as a gem, you need to explicitly enable it in config/environments.rb:

config.gem 'JasonKing-inline_attachment', :lib => 'inline_attachment'

Otherwise, you get a NOMETHOD message.

Otherwise, you have to install it as a plugin:

script/plugin install git://github.com/JasonKing/inline_attachment.git

The other issue is that calling render_message and passing in award => award parameter will return a:

You have a nil object when you didn't expect it!
The error occurred while evaluating nil.name

It appears that like @cid, you have to set award object as an instance variable:

@award = award

and so. . .

part 'multipart/related' do |p|
p.parts << ActionMailer::Part.new(:content_type => 'text/html',
:body => render_message('certificate.text.html.erb',
:award => @award, :cid => @cid))

Not sure if it was the change in inline_attachment code or the Rail version change that caused it or just an oversight. Considering the last couple errata I have submitted, I am inclined to believe the last one one. :)

(No, I won't hold it against you. Trying to figure out the bugs actually helped me out in learning rails, so its all good, as they say in the South. Thanks for a great publication!).

Rilindo Foster 
Printed Page 295
Example 17-10

Follow up on Example 17-10.

Actually, I forgot to mention that I tested it on the older Inline_attachment versions (0.3.0 n3 0.4.0), so it likely not InlineAttachment that is the issue, but I could be wrong. . .

Rilindo Foster