Learning Rails 5

Errata for Learning Rails 5

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. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

Color Key: Serious Technical Mistake Minor Technical Mistake Language or formatting error Typo Question Note Update



Version Location Description Submitted By Date Submitted Date Corrected
Printed
Page xxii
1st sentence

Link for code points to invalid page instead of https://github.com/bbulpett/LR5

Note from the Author or Editor:
I am baffled as to why this has been so hard to fix. I have emailed oreilly multiple times about this. The book references this link for code: http://oreil.ly/LearningRails5. This link is a 'page not found' it should redirect to https://github.com/bbulpett/LR5

S Chris Harmon  Sep 14, 2016  Feb 24, 2017
PDF
Page 45
Example 4-2

Figure 4-1 shows the result of code in Example 4-2. However, the "Hello" heading is missing. I think this line should be before the form_tag code in order to print the "Hello Zaphod" heading shown in Figure 4-2 <h1>Hello <%= @name %></h1>

Note from the Author or Editor:
The text should have the addtion of <h1>Hello <%= @name %></h1> above the form_tag, so it shold look like: <h1>Hello <%= @name %></h1> <%= form_tag action: 'sign_in' do %> <p>Enter your name: <%= text_field_tag 'visitor_name', @name %></p> <%= submit_tag 'Sign in' %> <% end %> Leave the bold in place, and the new text should not be bold.

Eder Andrés Ávila Niño  Sep 10, 2016  Feb 24, 2017
PDF
Page 51
5th Paragraph

The indentation for the two inner lines don't match, which is a syntax error: create_table :entries do |t| t.string :name t.timestamps end

Note from the Author or Editor:
He's right. The line t.string :name should be move to the right one character.

Anonymous  Sep 12, 2016  Feb 24, 2017
PDF
Page 58
id section

The id value by mistake is entered as 11, which should be 1: ... WHERE "entries"."id" = ? LIMIT 1 [["id", 11]] should be: WHERE "entries"."id" = ? LIMIT 1 [["id", 1]]

Note from the Author or Editor:
See: https://gist.github.com/marklocklear/0b7609fa94ec22a46ed6c03fee16771a Note, change from [["id", 11]] to [["id", 1]]

Anonymous  Sep 12, 2016  Feb 24, 2017
PDF
Page 60
1st paragraph

"By default, the order will sort in ascending order, so the option just shown would sort family_name values in ascending order, using given_name as a second sort field when family_name values are the same." I think we need just a bit more context or a little code example to show how family_name and given_name would be sorted. Maybe something like this code? Entry.sort(family_name: "asc", given_name: "asc")

Note from the Author or Editor:
I reworked this section to look like this: https://gist.github.com/marklocklear/fc5d41d469fbdc0b9e74b772425ee522 Changed the verbiage after the Entry.order statement, and added an example with city.

Eder Andrés Ávila Niño  Sep 10, 2016  Feb 24, 2017
PDF
Page 104
Below Figure 6-4

Values in arrays are missing wrapping single-quotes as found higher up on this page: <%= f.select :country, [ [Canada, Canada], [Mexico, Mexico], [United Kingdom, UK], [United States of America, USA] ], :selected => USA%>

Note from the Author or Editor:
This one is weird because it what you see in the gist what is in the repo, and displays correctly (with quotes) in my browser. Somehow the quotes did not make it to print. Just be sure the single quotes show up in print. For visual reference should look like this: https://snag.gy/wKeM6A.jpg https://gist.github.com/marklocklear/d5c35cbe16c9140f3add690aea32d880

Anonymous  Nov 27, 2016  Feb 24, 2017
PDF
Page 109
Figure 6-9

'button_select' should be bold as the name of the method has changed, as in: def button_select(model_name, target_property, button_source)

Note from the Author or Editor:
See line 3 of https://gist.github.com/marklocklear/7f01dbaae59864e9a7bce91e7a736d92 Add strong tag to button_select

Anonymous  Nov 27, 2016  Feb 24, 2017
PDF
Page 135
store_photo method

The file opening mode should be enclosed by quotes. Otherwise, it will be a syntax error. So instead of File.open(photo_filename, wb) do |f| f.write(@file_data.read) end We should code this: File.open(photo_filename, "wb") do |f| f.write(@file_data.read) end

Eder Andrés Ávila Niño  Sep 13, 2016  Feb 24, 2017
PDF
Page 137
PHOTO_STORE code

The arguments for building the photo file path should be enclosed by quotes. So instead of PHOTO_STORE = File.join Rails.root, public, photo_store it should be PHOTO_STORE = File.join(Rails.root, "public", "photo_store") Otherwise, Ruby will mark two errors because of the public keyword and the non-defined photo_store method.

Eder Andrés Ávila Niño  Sep 13, 2016  Feb 24, 2017
PDF
Page 137
photo_filename and photo_path methods

Both methods photo_filename and photo_path have a the missing '#' sign for proper string interpolation. Otherwise, all people will have this very same photo file name: {id}.{extension} So, instead of File.join PHOTO_STORE, "{id}.{extension}" We should code this: File.join(PHOTO_STORE, "#{id}.#{extension}") The same for: "/photo_store/{id}.{extension}" It should be: "/photo_store/#{id}.#{extension}"

Note from the Author or Editor:
Kristen, I am hoping you will be able to fix this one also. The # are in the code , but I just have the wrong block code. I think its clear from the description what needs to happen. Please let me know if you have questions, or you need me to try and fix this.

Eder Andrés Ávila Niño  Sep 13, 2016  Feb 24, 2017
PDF
Page 164
def create method

Minor typo error: missing quotes for the notice (string) argument. format.html { redirect_to student_awards_url(@student), notice: Award was successfully created. } It should be: format.html { redirect_to student_awards_url(@student), { notice: "Award was successfully created." } }

Note from the Author or Editor:
Two notice statements here that will need quotes.

Eder Andrés Ávila Niño  Sep 14, 2016  Feb 24, 2017
PDF
Page 165
def update method

Minor typo error. Missing quotes for the notice (string) argument. format.html { redirect_to student_awards_url(@student), notice: Award was successfully updated. } It should be: format.html { redirect_to student_awards_url(@student), notice: "Award was successfully updated." }

Eder Andrés Ávila Niño  Sep 14, 2016  Feb 24, 2017
PDF
Page 177
Source code

A little typo. There are three flash[:notice] assignments that require quotation marks: flash[:notice] = Student was successfully enrolled flash[:error] = Student was already enrolled flash[:notice] = Course was successfully deleted They should be: flash[:notice] = "Student was successfully enrolled" flash[:error] = "Student was already enrolled" flash[:notice] = "Course was successfully deleted"

Note from the Author or Editor:
This is true for the flash messages in both sets of the code at the top and bottom of the page.

Eder Andrés Ávila Niño  Sep 14, 2016  Feb 24, 2017
PDF
Page 179
application.html.erb

Minor typo. Code for rendering the navigation partial requires quotation marks: <%= render navigation %> It should be: <%= render "navigation" %>

Note from the Author or Editor:
See https://gist.github.com/marklocklear/1c3014c00ae8d04466c23ac440786d16 Correct in repo, and on my local viewer. Should look like: https://snag.gy/NPQ65x.jpg

Eder Andrés Ávila Niño  Sep 14, 2016  Feb 24, 2017
PDF
Page 183
upper code

Minor typo. The link_to for the courses collection requires quotation marks: <%= link_to Courses, courses_student_path(@student) %> | It should be: <%= link_to "Courses", courses_student_path(@student) %> |

Note from the Author or Editor:
See https://gist.github.com/marklocklear/f94c63d4ba993cac84a09819a51976b4 Another one where it looks right in the repo, and on my local viewer, but wrong in the book. For reference should look like: https://snag.gy/vGurLd.jpg Note the quotes and bold that are not in the book.

Eder Andrés Ávila Niño  Sep 14, 2016  Feb 24, 2017