We try to keep our books accurate, but sometimes mistakes creep
in. This page lists the errors submitted by our astute readers.
If you've found a new error, please
submit it.
The latest version of the book is P6.0,
released over 2 years ago.
If you've bought a PDF of the book and would like to upgrade
it to this version (for free), visit your
home page.
| PDF |
Paper |
Description |
Found in |
Fixed in |
| i |
i |
#23216: Dave says: For general help with Rails and examples in the book, I recommend the Rails mailing list at http://lists.rubyonrails.org/mailman/listinfo/rails
We need a forum for problems encountered while working through examples and better descriptions of how to fix the Mac Tiger mysql problems--Richard Williams #23216: Dave says: For general help with Rails and examples in the book, I recommend the Rails mailing list at http://lists.rubyonrails.org/mailman/li ...more...
|
P2.0
25-Aug-05
|
|
|
1 |
#24344: You should put together a comprehensive list of all the naming conventions in one place. "id" is in the begining of the book, datetime on page 116 and the sloppy wrapup on page 188 just doesn't cut it.--Old C Hippie #24344: You should put together a comprehensive list of all the naming conventions in one place. "id" is in the begining of the book, datetime on pag ...more...
|
P4.0
21-Mar-06
|
|
| 5 |
|
#24234: Currently, all downloadable code linked from the PDF book has the Content-Type set to "text/html". This will make most browsers show the code in one huge line without breaks.
It would be nice if all downloadable code had the Content-Type set to "text/plain", so browsers show them nicely formatted.
In a perfect world, you would be able to set the Content-Type to "text/x-ruby-source" or something like that, and the browser would show the code with syntax highlight... oh, well...--Marcus Brito #24234: Currently, all downloadable code linked from the PDF book has the Content-Type set to "text/html". This will make most browsers show the code ...more...
|
P4.0
03-Mar-06
|
|
| 5 |
|
#24514: "In the margin, you--jeff e
|
P4.0
21-Apr-06
|
|
| 6 |
|
#24088: "This book documents Rails V1.0, which became available in mid 2005" should be "This book documents Rails 1.0, which became available on December 13, 2005"
Also "the last release before Rails 1.0" should be "one of the last releases before Rails 1.0"--Peter T Bosse II #24088: "This book documents Rails V1.0, which became available in mid 2005" should be "This book documents Rails 1.0, which became available on Decem ...more...
|
P4.0
08-Feb-06
|
|
| 15 |
|
#24522: "Sometimes these class-level methods return collections of objects.
Order.find(:all, :conditions => "name='dave'") do |order|
puts order.amount
end"
Find returns a collection but requires an iterator to call the block on it. So I think you're missing an ".each" before the "do".--Kieron Browne #24522: "Sometimes these class-level methods return collections of objects.
Order.find(:all, :conditions => "name='dave'") do |order|
puts order.a ...more...
|
P4.0
23-Apr-06
|
|
| 20 |
|
#25308: Well one drop for the general context... I must confess I haven't bought that book yet, I'm just testing it.
It's my first contact with Rails, Ruby and even MySQL (began yesterday)
Your explanation for the installation on windows is nice, but too "simple". In fact since there isn't another way to install Rails without dowloading it thru gem, you need to care about people who are "behind" a firewall with NAT. I suspected I needed to tell to "gem" that I was using a proxy ..but where and how !!!. I checked in many files in the gem directories but without succes. Also unlucky on official Rails homepage. A few haurs later I fanally found the info in a fack in the wiki version for Rail.
Please specify the following parameter for people using proxies :
-p http://proxy:port (where proxy is the name or IP of the proxy server and port the port number used for internet access especially when "NATed")
=> ex :
gem install rails --include-dependencies -p http://192.252.1.2:8080
Sorry for my bad english, 'cause I'm a poor frenchy :)
Can feedback me on kagejin0@yahoo.fr
other Erratums will follow--Koguma #25308: Well one drop for the general context... I must confess I haven't bought that book yet, I'm just testing it.
It's my first contact with Rails ...more...
|
P4.0
21-Jun-06
|
|
|
23 |
#25285: In the fifth printing of the book, the link to Lucas Carlson's instructions for Ruby on Mac OS X Tiger leads to an error page.--Jeffrey Yu
|
P4.0
17-Jun-06
|
|
| 33 |
|
#24403: The "Making Development Easier" box is very valuable information, but I question whether this is the best place to put it. I would have rather read something about how close .rhtml is to a JSP. In any case, talking about Webrick and its use in production at this point sort of threw me off track a bit. Just a suggestion that something else might be more effective here. (-:--Lindy Mayfield #24403: The "Making Development Easier" box is very valuable information, but I question whether this is the best place to put it. I would have rathe ...more...
|
P4.0
03-Apr-06
|
|
| 50 |
|
#24405: I am going through the tutorial with you: After "rails depot" and then "cd depot" and then "ls" my directories are different from yours. For example I don't have CHANGELOG or Rakefile.--Lindy #24405: I am going through the tutorial with you: After "rails depot" and then "cd depot" and then "ls" my directories are different from yours. For ...more...
|
P4.0
03-Apr-06
|
|
| 50 |
|
#24533: The code at the bottom of the page is unclear. What should one do with it? Type it at an 'mysql' prompt? If so, the result is an error (1046) that states that no database is selected. #24533: The code at the bottom of the page is unclear. What should one do with it? Type it at an 'mysql' prompt? If so, the result is an error (104 ...more...
|
P4.0
26-Apr-06
|
|
| 50 |
|
#25309: I'm using MYSQL 5.0.22 the current last stable version on windows XP SP2. It's my first enccounter with MYSQL so my problems could be related to my lack of experience.
Nevertheless in your databases creation process thru the command-line I got some trouble.
In fact the "grants" didn't work because they expect to have the users created before. For instance thru a CREATE USER 'dave'@'localhost' and CREATE USER 'prod'@'localhost' identified by 'wibble'.
The bad point is that by doing so (maybe a new default behavior of Mysql) all the priviledges are granted to these users. So we need to restrict thme by command line or by using a GUI (I advise to use MySQL-Front, it's a nice free toy)
=> same erratum on page 51 when you create the table products thru the sql script. By doing so you're using an ODBC user. So you need to create an 'ODBC'@'localhost'.
Feedbacks on kagejin0@yahoo.fr--Koguma #25309: I'm using MYSQL 5.0.22 the current last stable version on windows XP SP2. It's my first enccounter with MYSQL so my problems could be related ...more...
|
P4.0
21-Jun-06
|
|
| 51 |
|
#23994: you might want to add "-u dave" to the mysql statement--Chad Bearden
|
P4.0
26-Jan-06
|
|
| 51 |
|
#24534: When one types the following string (mysql depot_development <db/create.sql), the result is an ->. What then? This entire section is unclear.
|
P4.0
26-Apr-06
|
|
| 52 |
|
#24116: It seems that the rails script now adds the application to database.yml:
database: depot_development
It automatically replaces the rails_development with depot_development.
--John Crowhurst #24116: It seems that the rails script now adds the application to database.yml:
database: depot_development
It automatically replaces the rails ...more...
|
P4.0
12-Feb-06
|
|
| 52 |
|
#24409: Not sure if you mention this later or not, but for Windows there needs to be:
port: 3306
in the file. And for Linux there needs to be, for example:
port: 3306
socket: /var/lib/mysql/mysql.sock
--Lindy #24409: Not sure if you mention this later or not, but for Windows there needs to be:
port: 3306
in the file. And for Linux there needs to be, ...more...
|
P4.0
04-Apr-06
|
|
| 52 |
|
#25310: Depot_xxxx are already correctly set in database.yml.
But as you said after, I advise to put 'dave' as username in development and test. The system is using root by default and since no password is provided this will lead to an error in the script generation on page 53.
P.S. : I have one more parameter in the database.yml version.. host: localhost
Feedback to kagejin0@yahoo.fr--Koguma #25310: Depot_xxxx are already correctly set in database.yml.
But as you said after, I advise to put 'dave' as username in development and test. The ...more...
|
P4.0
21-Jun-06
|
|
| 53 |
|
#24500: Repeated reinstallations of entire package on OSX 10.4.6 continually produce the following:
./script/../config/../config/environment.rb:8: warning: already initialized constant RAILS_GEM_VERSION
exists app/controllers/
exists app/helpers/
exists app/views/admin
exists test/functional/
dependency model
exists app/models/
exists test/unit/
exists test/fixtures/
identical app/models/product.rb
identical test/unit/product_test.rb
identical test/fixtures/products.yml
Unknown database 'depot_development'
Error is not documented in footnotes and I can't find anything on it an forums. Any ideas? #24500: Repeated reinstallations of entire package on OSX 10.4.6 continually produce the following:
./script/../config/../config/environment.rb:8: ...more...
|
P4.0
19-Apr-06
|
|
| 53 |
|
#24510: for,
depot> ruby script/generate scaffold Product Admin
I had to use infor from http://dev.rubyonrails.org/ticket/200 to get it to work on Linux (gentoo distro).
--Mike Nelson #24510: for,
depot> ruby script/generate scaffold Product Admin
I had to use infor from http://dev.rubyonrails.org/ticket/200 to get it to work ...more...
|
P4.0
21-Apr-06
|
|
| 53 |
|
#24532: When attempting to run the line "ruby script/generate scaffold Products Admin" in Windows, I receive the following error listed in the book (addressed only for Mac): Before updating scaffolding from new DB schema, try creating a table for your model (Product). #24532: When attempting to run the line "ruby script/generate scaffold Products Admin" in Windows, I receive the following error listed in the book (a ...more...
|
P4.0
26-Apr-06
|
|
| 53 |
|
#24556: On OS X (10.4.3), when I attempt to run script/generate scaffold Product Admin, I get the following error:
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occured while evaluating nil.each
Not sure how to proceed. I have been on the IRC channels looking for help but to no avail. Any ideas? #24556: On OS X (10.4.3), when I attempt to run script/generate scaffold Product Admin, I get the following error:
You have a nil object when you d ...more...
|
P4.0
30-Apr-06
|
|
|
54 |
#24212: While creating the databases, the user should issue the command:
mysql> grant all on depot_development.* to 'dave'@'localhost';
There is no indication if the user should substitue dave with the user's own logon name. I know this is a book about Rails, but some minor SQL explanations would be nice. Could even be fine text at bottom of page!--John #24212: While creating the databases, the user should issue the command:
mysql> grant all on depot_development.* to 'dave'@'localhost';
There is n ...more...
|
P4.0
28-Feb-06
|
|
|
54 |
#24283: After setting database privileges, if you exit mysql without typing the magic words "flush privileges", the privileges you've just set won't take effect.--Daniel Torrey #24283: After setting database privileges, if you exit mysql without typing the magic words "flush privileges", the privileges you've just set won't t ...more...
|
P4.0
11-Mar-06
|
|
|
57 |
#26704: ppc:~/work/depot tomcoady$ ruby script/generate scaffold Product Admin
./script/../config/boot.rb:18:in `require': No such file to load -- rubygems (LoadError)
from ./script/../config/boot.rb:18
from script/generate:2:in `require'
from script/generate:2--Tom Coady #26704: ppc:~/work/depot tomcoady$ ruby script/generate scaffold Product Admin
./script/../config/boot.rb:18:in `require': No such file to load -- ru ...more...
|
P1.0
03-Dec-06
|
|
|
57 |
#26705: Solution to my tech error:
ppc:~/src/rubygems-0.8.11 tomcoady$ sudo ruby setup.rb
ppc:~/work/depot tomcoady$ sudo gem install -v=1.1.6 rails
--Tom Coady
|
P1.0
03-Dec-06
|
|
|
57 |
#25428: After running "ruby script/generate scaffold Product Admin" on linux box using SuSE v10.0 and MySql Ver 14.12 Distrib 5.0.22, I get an error stating /tmp/mysql.sock cannot be found. I resolved this by searching for mysql.sock and creating soft link to it from /tmp dir. e.g. ln -s /var/lib/mysql/mysql.sock tmp/mysql.sock I was then able to get form depicted on p.58--Mark Glass #25428: After running "ruby script/generate scaffold Product Admin" on linux box using SuSE v10.0 and MySql Ver 14.12 Distrib 5.0.22, I get an error s ...more...
|
P4.0
09-Jul-06
|
|
|
57 |
#23940: The 'gotcha' notes (3,4,& 5) are useful. You might consider adding another...
If you get Routing Error: Recognition failed for '/admin', make sure that you're starting WEBrick from the depot folder and not the demo folder.--Jason #23940: The 'gotcha' notes (3,4,& 5) are useful. You might consider adding another...
If you get Routing Error: Recognition failed for '/admin', ...more...
|
P3.0
12-Jan-06
|
|
|
57 |
#26760: I think the code should read
ruby script/generate scaffold Products Admin
since the table was created with the name products (plural, not singular)
otherwise when attempting to load the page, I get a recognition failed error
I made that simple change and it worked--Clark Alexander #26760: I think the code should read
ruby script/generate scaffold Products Admin
since the table was created with the name products (plural, not ...more...
|
P6.0
16-Dec-06
|
|
|
57 |
#31649: My version of the paper book is actually P5 (2006-02-16). The problem is that scaffold has changed. I am running Rails 2.02 and the following command will work.
ruby script/generate scaffold Product id:int title:varchar description:text image_url:varchar price:decimal -f
So, in answer the the question "That wasn't hard now, was it?" is actually "it was a nightmare"!!--Antony Scott #31649: My version of the paper book is actually P5 (2006-02-16). The problem is that scaffold has changed. I am running Rails 2.02 and the following ...more...
|
P4.0
11-Apr-08
|
|
|
57 |
#26821: Okay, so this is a gripe. As noted previously, the link to Lucas Carlson's fix is no longer to be found as described. However, you can go to the Internet Archive website and reconstruct the script to run locally. That being said, I have done so and have reinstalled Ruby and MySQL and am still getting the dreaded "--ray palermo #26821: Okay, so this is a gripe. As noted previously, the link to Lucas Carlson's fix is no longer to be found as described. However, you can go to t ...more...
|
P6.0
09-Jan-07
|
|
|
57 |
#24784: I've seen this error elsewhere but never a solution. Here goes: On page 57, I entered, at depot prompt,
ruby script/generate scaffold Product Admin
The error I get is:
"#28000Access denied for user 'root'@'localhost' (using password: NO)"
The author's statement after the description of this is: "That wasn't hard now, was it"...actually, it's turning out to be very hard.
I had to battle to get the commands going on page 54 too.
It really shouldn't be this hard...
--pat lynch #24784: I've seen this error elsewhere but never a solution. Here goes: On page 57, I entered, at depot prompt,
ruby script/generate scaffold Produc ...more...
|
P4.0
08-May-06
|
|
| 62 |
|
#24333: The unless clause of the validate method is wrong. To verify this, comment out 'validates_numericality_of :price' and try submitting a product without a price; you'll get a null constraint violation. Something like 'unless price && price >= 0.01' works better.--Kevin Christen #24333: The unless clause of the validate method is wrong. To verify this, comment out 'validates_numericality_of :price' and try submitting a produc ...more...
|
P4.0
19-Mar-06
|
|
| 62 |
|
#25300: In the eBook we have this code for product.rb:
errors.add(:price, "should be positive") unless price.nil? || price >= 0.01
Where as the downloadable code has the following:
errors.add(:price, "should be positive") unless price.nil? || price > 0.0
Notice that the last line compares "price > 0.0" instead of "price > 0.01"
--Max #25300: In the eBook we have this code for product.rb:
errors.add(:price, "should be positive") unless price.nil? || price >= 0.01
Where as the down ...more...
|
P4.0
21-Jun-06
|
|
| 62 |
|
#25301: Quote from second paragraph:
"Note that we only do the check if the price has
been set. Without that extra test we--Max
|
P4.0
21-Jun-06
|
|
| 62 |
|
#29155: Just a note for readers who may get put-off by the unknowability's of generated code-bases early on.
Should a user make an error in pluralisation in either the SQL or Scaffold command (e.g. product v.s. Products) the application fails with a NameError for the model name (activesupport 'load_missing_constant' in the trace) when trying to acess the 'admin' url.
I could only recover from this by deleting and recreating the whole application.
Running the Scaffold again overrode files, etc, but despite diffing between version controlled files before and after there was no visible reason why was stuck, and little info on Google addressed this.
This leaves me feeling I need to be very careful when running the Scaffold commands if you are deeper into your application development.--Liam Clancy (metafeather) #29155: Just a note for readers who may get put-off by the unknowability's of generated code-bases early on.
Should a user make an error in pluralisa ...more...
|
P6.0
28-May-07
|
|
| 63 |
63 |
#24557: Cannot "destroy" items.
Both file listings 66 & 67 omit ':post' argument in the link_to 'Destroy' line. The line should read:
<%= link_to 'Destroy', { :action => 'destroy', :id => product },
:confirm => "Are you sure?",
:post => true %>
--Randy W. Sims #24557: Cannot "destroy" items.
Both file listings 66 & 67 omit ':post' argument in the link_to 'Destroy' line. The line should read:
<%= link_t ...more...
|
P4.0
30-Apr-06
|
|
| 64 |
|
#24397: Link to ERb definition is not on page 31 as stated.--Pierre-Loïc Raynaud
|
P4.0
01-Apr-06
|
|
| 64 |
|
#25764: It took me quite some time when I was working through the sample code to figure out what was wrong. When editing the list.rhtml, I just erased what was there and worked through the example in the book, however, when I did that, I could never destroy any of the products that I had added. Look at the code generated from the scaffold, I realized that the example in the book is missing something vital. In File 67 the Destroy code should be replaced with this:
<td><%= link_to 'Destroy', { :action => 'destroy', :id => product }, :confirm => 'Are you sure?', :post =>true %></td>
and in File 68 it should be:
<%= link_to 'Destroy', { :action => 'destroy', :id => product },
:confirm => "Are you sure?",
:post => true %>
The line :post => true is missing in both files. Anyways, hope this helps.--David Kartik #25764: It took me quite some time when I was working through the sample code to figure out what was wrong. When editing the list.rhtml, I just erase ...more...
|
P6.0
21-Aug-06
|
|
| 65 |
|
#25475: ITERATION A4
|
P4.0
18-Jul-06
|
|
| 65 |
|
#24254: Relative URL's not allowed by current validates_format_of :with parameter; where the text says: "Put some images in the public/images directory and enter some product descriptions, and the resulting product listing might look something like Figure 6.7, on the next page.", the current validation functionality in the model (/depot/app/models/product.rb) will not allow the correct relative url (i.e. /images/sk_utc_small.jpg) to be entered, since it requires a full URL.
In the downloadable code for depot4/app/models/product.rb, the regular expression should be commented out or deleted, and replaced with one allowing relative url's for the images.
And this should be among the modifications mentioned in the text for Iteration A4.--Victor Kane #24254: Relative URL's not allowed by current validates_format_of :with parameter; where the text says: "Put some images in the public/images director ...more...
|
P4.0
08-Mar-06
|
|
| 65 |
|
#25311: ":post => true" is missing after :confirm => "are you sure?".
Without this you cannot destroy anything :)
Feedback to Kagejin0@yahoo.fr --Koguma
|
P4.0
21-Jun-06
|
|
|
69 |
#25734: The list action for Destroy as it is in the book didn't work for me: Clicking Destroy would pop up the confirmation dialog, but choosing ok would just refresh the list but not delete the product. After looking at the initially generated scaffolding code, I've noticed that this included an additional parameter
:post => true
After I changed the whole line to
<%= link_to 'Destroy', { :action => 'destroy', :id => product },
:confirm => "Are you sure?", :post => true %>
the destroy action worked as expected.
PS: It might be a version issue. I've observed it with Rails 1.1.6
PPS: I have the 5th printing, February 06. This not available from the version drop down box.--Stefan Moser #25734: The list action for Destroy as it is in the book didn't work for me: Clicking Destroy would pop up the confirmation dialog, but choosing ok wo ...more...
|
P6.0
17-Aug-06
|
|
|
69 |
#24228: The text starting: 'put some images in the public/images directory' led me to think that the correct url for the images in the production form was /public/images/xxx.jpg Actually, after some considerable head scratching, it turns out the base for static resources is public, so the correct href is /images/xxx.jpg. The text gives no inkling of this..--Michael Karliner #24228: The text starting: 'put some images in the public/images directory' led me to think that the correct url for the images in the production form ...more...
|
P4.0
03-Mar-06
|
|
|
69 |
#24313: The images do not display when added in relative format.
In the list.rhtml file you should use
<img width="100" height="80" src="/depot/images/<%= product.image_url %>" /> instead. Then when adding an image just add the image name. It would be bad practice to use images that begin with http: anyway, especially if those images are from another site.--scottrad #24313: The images do not display when added in relative format.
In the list.rhtml file you should use
<img width="100" height="80" src="/depot/ima ...more...
|
P4.0
17-Mar-06
|
|
| 71 |
|
#24420: We’ll also take this opportunity to tidy up the index.rhtml view in app/views.
it should be: app/views/store--kibo
|
P4.0
07-Apr-06
|
|
| 71 |
|
#23965: This is the first time depot.css is mentioned. It has to be included in the project for proper view display. Needs to be copied from the sample code.--james patrick mclemore #23965: This is the first time depot.css is mentioned. It has to be included in the project for proper view display. Needs to be copied from the sam ...more...
|
P4.0
18-Jan-06
|
|
| 71 |
|
#26291: I'd rather remove the line numbers from listing of layout store.rhtml. With line numbers this sample is uncomfortable to copy/paste.
|
P6.0
18-Oct-06
|
|
|
73 |
#26711: The suggested code does not work for me but I found the right code elsewhere in the code bundle - detail here to avoid unititiated Product: http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/6b7333e92877c94d/8cd2f0bde6dd1a3f--Tom Coady #26711: The suggested code does not work for me but I found the right code elsewhere in the code bundle - detail here to avoid unititiated Product: ht ...more...
|
P1.0
04-Dec-06
|
|
| 76 |
|
#24091: As was previously stated, " In the implementaion of find_cart, the 3rd line reads "session[:cart] ||=Cart.new" This line should read "@cart = session[:cart] ||= Cart.new" " I ran into an issue in which if I accessed /store or /store/display_cart directly in a fresh (meaning session cookie-less) browser window, I could refresh the page as many times as I want and keep the same session, however if I added an item to the cart or otherwise changed pages in the browser, it would set a new cookie everytime (even everytime I refreshed the new page). Making the change noted in the quote above fixed the issue. I'm running Ruby 1.8.2, Rails 1.0.0 on a Win XP Pro SP2 pc, and I caught the error by adding the line <%= debug session %> to both my index.rhtml and display_cart.rhtml (in store views). #24091: As was previously stated, " In the implementaion of find_cart, the 3rd line reads "session[:cart] ||=Cart.new" This line should read "@cart = ...more...
|
P4.0
09-Feb-06
|
|
| 76 |
|
#24888: At first sight this approach to database maintenance is
attractive--Gordon Thiesfeld
|
P4.0
17-May-06
|
|
| 76 |
|
#25164: As pointed out before, there is an error in
session[:cart] ||= Cart.new
I replaced the code with
session[@cart] ||= Cart.new
and it magically worked again
Need someone to explain this to me
#25164: As pointed out before, there is an error in
session[:cart] ||= Cart.new
I replaced the code with
session[@cart] ||= Cart.new
and it magi ...more...
|
P4.0
03-Jun-06
|
|
| 79 |
|
#23187: The hyperlink to page 474 that describes the << operator points to page 473.--Stephen Touset
|
P2.0
20-Aug-05
|
|
|
80 |
#25862: I made all the additions to the code to the end of making the cart
I get the rails error:
"You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occured while evaluating nil.size"
I don't know how to fix this--Gerry #25862: I made all the additions to the code to the end of making the cart
I get the rails error:
"You have a nil object when you didn't expect ...more...
|
P6.0
07-Sep-06
|
|
|
81 |
#24329: IWhen I run the sql at the bottom of the page to create the new table, I get an error "ERROR 1005 at line 13: Can't create table '.\depot_development\line_items.frm' <errno: 150>"
MySQL (I'm running 4.0.16) needs an index to be declared on the foreign key can be created. Like so:
create table line_items (
id int not null auto_increment,
product_id int not null,
quantity int not null default 0,
unit_price decimal(10,2) not null,
primary key (id),
index ix_line_items (product_id),
constraint fk_items_product foreign key (product_id) references products(id)
) TYPE=InnoDB;
Also MyIsam is the default table type, so I've forced innodb for the foreign key support. Not sure if that would have affected anything though.--Nick Coyne #24329: IWhen I run the sql at the bottom of the page to create the new table, I get an error "ERROR 1005 at line 13: Can't create table '.\depot_deve ...more...
|
P3.1
18-Mar-06
|
|
|
81 |
#25904: similar to the error already reported...
ERROR 1064 (42000) at line 12: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '
product_id int not null,
quantity int not null default 0,
unit_price decimal' at line 2
(mysql 5.0.21)
typing the code as is on the bottom of 81, mySQL is kicking back this error. help?--dave rupert #25904: similar to the error already reported...
ERROR 1064 (42000) at line 12: You have an error in your SQL syntax; check the manual that corresp ...more...
|
P1.0
12-Sep-06
|
|
| 81 |
|
#25318: items.sizes is nil !!!
|
P4.0
22-Jun-06
|
|
| 82 |
|
#24395: Others have mentioned this error and I've tried all their suggestions but I can't get any to work. Upon testing the cart to see if it will return the @item.size of the cart's contents I get an error of:
NoMethodError in Store#display_cart
Showing app/views/store/display_cart.rhtml where line #2 raised:
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occured while evaluating nil.size
Now what? I've rebooted the WebBrick server. Killed the browser window after deleting all the cookies, session data, etc. I'm using RadRails so I closed it as well. Booted the server back up from a command line and get the same option. I've searched the internet through and tons of users have had this problem but there are no solutions.
Please, oh please, help!--Philip Joyner #24395: Others have mentioned this error and I've tried all their suggestions but I can't get any to work. Upon testing the cart to see if it will ret ...more...
|
P4.0
31-Mar-06
|
|
| 83 |
|
#24335: find:
Using the model declaration forces Rails to load the user model class early,
replace with:
Using the model declaration forces Rails to load the cart model class early,
explanation: you're talking about the "cart" model not the "user" model. #24335: find:
Using the model declaration forces Rails to load the user model class early,
replace with:
Using the model declaration forces Rails ...more...
|
P4.0
20-Mar-06
|
|
| 84 |
|
#24393: The online version of the file for '...app/models/cart.rb' (http://media.pragprog.com/titles/rails/code/depot9/app/models/cart.rb) differs in the fourth last line from the class definition in the book.
Book (pp 83-4):
...
@total_price += item.unit_price
...
Downloadable file 'cart.rb':
...
@total_price += product.price
...
The dowloadable file seems to be correct.--Gus Gollings #24393: The online version of the file for '...app/models/cart.rb' (http://media.pragprog.com/titles/rails/code/depot9/app/models/cart.rb) differs in ...more...
|
P4.0
30-Mar-06
|
|
|
85 |
#23910: The display_cart method on this page must be placed in the store controller *before* the private declaration line that's already in that class definition. I may be the only person who is paying so close attention to getting the method right that I overlook this placement but doing so results in an extended (and informative) debugging session as Rails complains it has no method called "display_cart".--Dan Shafer #23910: The display_cart method on this page must be placed in the store controller *before* the private declaration line that's already in that class ...more...
|
P3.1
02-Jan-06
|
|
|
85 |
#24422: In reference to problem #2532, "You have a nil object when you didn't expect it!", I also ran into the problem in chapter 8. I typoed a simple part of the application, tested it, fixed the typo, then got that error no matter what I tried (even deleting everything and typing it up again). The answer was indeed to delete session data: depot/tmp/sessions--April #24422: In reference to problem #2532, "You have a nil object when you didn't expect it!", I also ran into the problem in chapter 8. I typoed a simpl ...more...
|
P2.0
07-Apr-06
|
|
|
85 |
#26229: When looking at "depot/public/store/display_cart" with my browser I was getting the error:
undefined local variable or method `find_cart' for #<StoreController:0x4080b768>
I then checked the downloadable Code snippets and noticed the find_cart method defined in File 75. I added this method to my code (as I was typing it from the book) and things worked.
It should say in the book to add the find_cart method (it doesn't).
(note: the version I'm using is:
Third Printing, September 2005
Version: 2005-9-13
(the closest option to submit this erratum was P3.0 - September 29))--Sean Lerner #26229: When looking at "depot/public/store/display_cart" with my browser I was getting the error:
undefined local variable or method `find_cart' f ...more...
|
P3.0
12-Oct-06
|
|
|
85 |
#24256: Re #2532 - This also happend to me running under Webrick. The solution was to both close the browser and restart Webrick. Hope this helps the other reader.--brian #24256: Re #2532 - This also happend to me running under Webrick. The solution was to both close the browser and restart Webrick. Hope this helps th ...more...
|
P1.0
09-Mar-06
|
|
| 86 |
|
#29669: Concerning the invalid IDs of objects in the URL line: it is not certain that an exception will always be thrown. I assume that the ID field, extracted from the URL, is transformed to a number without any checks made. So if there is a product with ID=0 in the database, it is actually added in the cart! This is way worse than crackers looking at an exception report page! One solution is to make sure somehow that the database starts counting from 1, but this doesn't make me feel secure enough. I believe that there should be further error checks on the ID parsing level.--Nikos Mouchtaris #29669: Concerning the invalid IDs of objects in the URL line: it is not certain that an exception will always be thrown. I assume that the ID field, ...more...
|
P1.0
16-Sep-07
|
|
|
87 |
#24448: In regard to the common error
"NoMethodError in Store#display_cart
Showing app/views/store/display_cart.rhtml where line #5 raised:
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occured while evaluating nil.each
"
I found that I had a typo in the store_controler.rb
I had entered.
---
def display_cart
@cart = find_cart
@items = @cart_items
end
---
but correct code is
---
def display_cart
@cart = find_cart
@items = @cart.items
end
---
Oh the joys of being a newbie!!! 5 hours of head scratching for that one!--glenn #24448: In regard to the common error
"NoMethodError in Store#display_cart
Showing app/views/store/display_cart.rhtml where line #5 raised:
You ...more...
|
P4.0
12-Apr-06
|
|
|
88 |
#24296: Editing cart.rb in order to enable the quantity to increment requires a WebTrick restart to work properly.--Bob Clewell
|
P2.0
15-Mar-06
|
|
| 90 |
|
#24288: The file link beside "<% @page_title = "Your Pragmatic Cart" -%>" is File 29. File 29 contains the fmt_dollars() helper. fmt_dollars() isn't defined until later on PDF p93. Perhaps the file link on PDF p90 should be to a version of display_cart.rhtml without fmt_dollars?--David Hislop #24288: The file link beside "<% @page_title = "Your Pragmatic Cart" -%>" is File 29. File 29 contains the fmt_dollars() helper. fmt_dollars() isn't d ...more...
|
P4.0
13-Mar-06
|
|
| 96 |
|
#24860: Unable to create the session table.
C:\apps\ruby\files\work\depot>rake --trace db:session:create
(in C:/apps/ruby/files/work/depot)
rake aborted!
Don't know how to build task 'db:session:create'
c:/apps/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:1449:in `[]'
c:/apps/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:455:in `[]'
c:/apps/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:1906:in `run'
c:/apps/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:1906:in `run'
c:/apps/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/bin/rake:7
c:/apps/ruby/bin/rake.bat:25
--Dave Pawson #24860: Unable to create the session table.
C:\apps\ruby\files\work\depot>rake --trace db:session:create
(in C:/apps/ruby/files/work/depot)
rake ...more...
|
P4.0
15-May-06
|
|
|
96 |
#25138: Flash messages are not displaying correctly using IE 6 sp2.
Results of invalid add_to_cart, empty_cart, etc no flash message appears to display.
Resizing IE window with mouse, flash message appears & disappears.
Resizing IE window with F11 key yields flash menu with missing bottom red line of the flash box.
Hitting key F11 to maximize IE, flash message displays --Steven #25138: Flash messages are not displaying correctly using IE 6 sp2.
Results of invalid add_to_cart, empty_cart, etc no flash message appears to dis ...more...
|
P3.0
31-May-06
|
|
|
98 |
#23580: using the fmt_dollars(item.unit_price) method, values less than 1, (values < 1) on the display_cart details show up as 0.00 but get added correctly to the total.--Jeff Bell #23580: using the fmt_dollars(item.unit_price) method, values less than 1, (values < 1) on the display_cart details show up as 0.00 but get added corr ...more...
|
P2.0
22-Nov-05
|
|
| 98 |
|
#24003: render_partial "form"
is now
render :partial => "form"--Dave Myron
|
P4.0
31-Jan-06
|
|
| 99 |
|
#25348: In "Putting Session in the Database", theres an extra "that." in the first paragraph (First, we--Jose Guerra
|
P4.0
27-Jun-06
|
|
| 99 |
|
#24239: Since file names can contain dashes (-) in them, it never struck me that check-out.rhtml was actually checkout.rhtml until I went to test the page. While a - in publishing means that a word is continued on the next line, it was misleading to me since it just so happened to be a file name that it was connecting to on the next line.--Ryan Prins #24239: Since file names can contain dashes (-) in them, it never struck me that check-out.rhtml was actually checkout.rhtml until I went to test the ...more...
|
P4.0
06-Mar-06
|
|
| 101 |
|
#26216: @order.line_items << @cart.items has to be @order.LineItems << @cart.items otherwise, ruby will report an unknown method "line_items" for the order object.--Volker #26216: @order.line_items << @cart.items has to be @order.LineItems << @cart.items otherwise, ruby will report an unknown method "line_items" for the ...more...
|
B1.0
10-Oct-06
|
|
|
103 |
#26369: 103 describes nirvana as a state of being, but it is really a state of not-being.--William Henderson
|
P6.0
24-Oct-06
|
|
| 103 |
|
#25340: Not filling the 4 fields is will highlight them correctly, but there is no message as shown on the screen copy.--koguma
|
P4.0
26-Jun-06
|
|
|
105 |
#23872: When I write code as in file 36:
options = [["select a payment option", ""]] + Order::PAYMENT_TYPES
select( "order", "pay_type", options)
I see an exception thrown by select. It expects the options parameter to respond to the "stringify_keys" method -- which array does not respond to. When I use a Hash instead of an array it works -- but unfortunately, I lose control over the ordering of the items by doing so. --Bill Burcham #23872: When I write code as in file 36:
options = [["select a payment option", ""]] + Order::PAYMENT_TYPES
select( "order", "pay_type", options)
...more...
|
P3.0
21-Dec-05
|
|
|
105 |
#24216: The file name checkout.rhtml is hyphenated to check-out.rhtm in paragraph 3. This is the only reference to the file name on the page where the code is set out.
If you use the hyphenated form, errors occur later on (page 108). checkout.rhtml is the correct name.--Rob Nichols #24216: The file name checkout.rhtml is hyphenated to check-out.rhtm in paragraph 3. This is the only reference to the file name on the page where the ...more...
|
P4.0
28-Feb-06
|
|
|
108 |
#24213: The code in checkout.rhtml that displays the error message is given as:
<%= error_messages_for(:order) %>
This works fine if there is an error present. However, when initially connecting to the page I get the error:
-------------------------------------------------
NoMethodError in Store#check-out
Showing app/views/store/check-out.rhtml where line #2 raised:
You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occured while evaluating nil.errors
Extracted source (around line #2):
1: <% @page_title = "Checkout" -%>
2: <%= error_messages_for(:order) %>
3: <%= start_form_tag(:action => "save_order") %>
4: <table>
5: <tr>
RAILS_ROOT: c:/web/depot/public/../config/..
-------------------------------------------------
It seems that on initial access a nil object is passed to error_messages_for.
However, if I change the line to:
<%= error_messages_for(:order) if @order %>
so that the presence of an object "order" is checked before passing anything to error_messages_for, the page works on opening from new and still displays the errors correctly.--Rob Nichols #24213: The code in checkout.rhtml that displays the error message is given as:
<%= error_messages_for(:order) %>
This works fine if there is an ...more...
|
P4.0
28-Feb-06
|
|
|
108 |
#24215: The problem with "error_message_for(:order)" occurs if you have named the page check-out.rhtml as given on page 105. If you correct the page name to checkout.rhtml, the page works correctly.--Rob Nichols #24215: The problem with "error_message_for(:order)" occurs if you have named the page check-out.rhtml as given on page 105. If you correct the page n ...more...
|
P4.0
28-Feb-06
|
|
|
109 |
#23894: Adding the scaffold stylesheet to the store layout seems to disable any formatting from the depot stylesheet. It doesn't seem to matter which I list first--scaffold styling always overrides (even though in html source the order does change). I've tried both firefox and ie. Interestingly, I looked in the download files and neither the chapter 9 nor the chapter 10 versions of the store layout files link to the scaffold stylesheet. #23894: Adding the scaffold stylesheet to the store layout seems to disable any formatting from the depot stylesheet. It doesn't seem to matter which ...more...
|
P4.0
30-Dec-05
|
|
|
109 |
#24473: #2855: The test "Just as with the administration validation, we need to add the scaffold.css styolesheet to our store layout file to get decent formatting for these errors.
<%= stylesheet_link_tag "scaffold", "depot", :media => "all" %>"
This was confusing for me at first as I thought it was meaning to add this entire line to the app\views\layout\store.rhtml file. When I checked the file this line existed.
What you really mean was that the string "scaffold" needs to be included as an argument to the stylesheet_link_tag call.
old <%= stylesheet_link_tag "depot", :media => "all" %>
new <%= stylesheet_link_tag "scaffold", "depot", :media => "all" %>
Looking back it seems easy but 30 minutes of confusion for me!
--glenn #24473: #2855: The test "Just as with the administration validation, we need to add the scaffold.css styolesheet to our store layout file to get decen ...more...
|
P4.0
13-Apr-06
|
|
|
109 |
#24289: There is an issue with the cascading style sheets being used here. The problem is that both the scaffold and depot stylesheets are combining to produce strange text size and the scaffold stylesheet is overriding the depot stylesheet's link and link-hover code. (it seems to be thse use of pt, px, ex, em text sizes... setting sizes then uses percentages of those newly set sizes) I believe this is an issue of IE and FireFox dealing with CSS differnetly than whatever browser/version the author wrote these examples with. We need a fix for this... almost everyone on the internet uses IE or FireFox.--Brian #24289: There is an issue with the cascading style sheets being used here. The problem is that both the scaffold and depot stylesheets are combining t ...more...
|
P2.0
13-Mar-06
|
|
|
115 |
#24141: "and a slightly different interaction style to the one we've been using so far." -> "... interaction style than the one we've been using so far."--Justin Johnson
|
P2.0
16-Feb-06
|
|
| 116 |
|
#26928: This may be a simple erratum. In the 7th row of the code, where in the function of ship, the "#{count_text} marked as shipped" should be "has shipped". --Ian #26928: This may be a simple erratum. In the 7th row of the code, where in the function of ship, the "#{count_text} marked as shipped" should be "has ...more...
|
P6.0
01-Feb-07
|
|
| 116 |
|
#23947: The code given for the ship method should not include the check (if count > 0) if you want to be able to show the intended message "No orders marked as shipped" flash message when no items are checked off before submitting the form.
--Alan M #23947: The code given for the ship method should not include the check (if count > 0) if you want to be able to show the intended message "No orders ...more...
|
P4.0
16-Jan-06
|
|
|
119 |
#24334: The admin.css file is not included in the code download, so we need to type this in manually :(--Nick Coyne
|
P3.1
19-Mar-06
|
|
|
119 |
#24472: The test "Just as with the administration validation, we need to add the scaffold.css styolesheet to our store layout file to get decent formatting for these errors.
<%= stylesheet_link_tag "scaffold", "depot", :media => "all" %>"
This was confusing for me at first as I thought it was meaning to add this entire line to the app\views\layout\store.rhtml file. When I checked the file this line existed.
What you really mean was that the string "depot" needed to be included as an argument to the stylesheet_link_tag call.
old <%= stylesheet_link_tag "depot", :media => "all" %>
new <%= stylesheet_link_tag "scaffold", "depot", :media => "all" %>
Looking back it seems easy but 30 minutes of confusion for me!--glenn #24472: The test "Just as with the administration validation, we need to add the scaffold.css styolesheet to our store layout file to get decent forma ...more...
|
P4.0
13-Apr-06
|
|
| 120 |
|
#24162: The code snippet given for login_controller.rb is missing an "end" statement at the end of it to close :
class LoginController < ApplicationController
--BrianWarren #24162: The code snippet given for login_controller.rb is missing an "end" statement at the end of it to close :
class LoginController < Applicatio ...more...
|
P4.0
21-Feb-06
|
|
|
122 |
#26252: The ship method only calls the pluralize method if the count is greater than 1:
def ship
count = 0
if things_to_ship = params[:to_be_shipped]
count = do_shipping(things_to_ship)
if count > 0
count_text = pluralize(count, "order")
flash.now[:notice] = "#{count_text} marked as shipped"
end
end
@pending_orders = Order.pending_shipping
end
Though the pluralize method has functionality to handle a zero checked for shipping submission:
def pluralize(count, noun)
case count
when 0: "No #{noun.pluralize}" # -- THIS ISN'T BEING UTILIZED
when 1: "One #{noun}"
else "#{count} #{noun.pluralize}"
end
end
I suggest removing the code that checks to see if the count is greater than one and instead always call the pluralize method:
def ship
count = 0
if things_to_ship = params[:to_be_shipped]
count = do_shipping(things_to_ship)
# REMOVED -- if count > 0
count_text = pluralize(count, "order")
flash.now[:notice] = "#{count_text} marked as shipped"
# REMOVED -- end
end
@pending_orders = Order.pending_shipping
end
Thanks,
Sean
sean@ttcrider.ca--Sean Lerner #26252: The ship method only calls the pluralize method if the count is greater than 1:
def ship
count = 0
if things_to_ship = params[:to ...more...
|
P3.0
14-Oct-06
|
|
| 122 |
|
#24217: The Login controller's "Add User" picture is incorrect. It has the stylesheet applied and looks much fancier.--Miles K. Forrest
|
P4.0
28-Feb-06
|
|
|
122 |
#24518: in File 48 (listed on page 122) -- the Pluralize method returns an error of 'undefined method' for 'pluralize'
|
P4.0
22-Apr-06
|
|
| 126 |
|
#22678: "Have a look at the source of the controller on page 478 and of the view on page 486."
The link to page 478 goes to page 475, and the link to page 486 goes to page 483.--Nathan Wright #22678: "Have a look at the source of the controller on page 478 and of the view on page 486."
The link to page 478 goes to page 475, and the link ...more...
|
B1.0
04-Jun-05
|
|
| 126 |
|
#24218: Link to page 490 actually goes to 487, and 498 goes to 495--Miles K. Forrest
|
P4.0
28-Feb-06
|
|
|
130 |
#26190: Whenever I try to add the initial user I am just forwarded to login/login. Is there another way just to add 1 user?--Sean
|
P6.0
08-Oct-06
|
|
|
134 |
#24131: The delete_user action uses a symbol reference for the redirection:
redirect_to(:action => :list_users)
While this obviously works it is a little confusing when in most similar cases you reference by a string:
redirect_to(:action => "index")
It seems as the references are interchangable in this context, but when writing test they are not - the same type must be used in the assert_redirected_to clause as in the controller.
It would be great to have a notice about the possible different coding styles, and the implications for the tests.
Maybe you could elaborate on wheter consistency is desirable as well.
(Or you could just change the reference, but that wouldn't be as interesting.)
--Daniel #24131: The delete_user action uses a symbol reference for the redirection:
redirect_to(:action => :list_users)
While this obviously works it is a l ...more...
|
P3.0
14-Feb-06
|
|
| 134 |
|
#24004: It seems that the generator for unit tests no longer generates the setup method (Rails 1.0.0) so the code in the PDF/Book doesn't match watch is actually produced.--Dave Myron #24004: It seems that the generator for unit tests no longer generates the setup method (Rails 1.0.0) so the code in the PDF/Book doesn't match watch ...more...
|
P4.0
31-Jan-06
|
|
| 138 |
|
#24246: the "assert_equal 29.95, @product.price" fails for me, even though product.price is 29.95. The only way to make this assert to pass it was changing the line to "assert_equal 29.95.to_s, @product.price.to_s" #24246: the "assert_equal 29.95, @product.price" fails for me, even though product.price is 29.95. The only way to make this assert to pass it was ch ...more...
|
P4.0
07-Mar-06
|
|
| 139 |
|
#24182: You might want to make mention of looking at the code for this test section. You tend to be very brief in your explanation and tend to leave the reader a little lost unless they aggressively hunt down the details of the code, etc.
For instance, setup() is never mentioned until *after* you say the code works. Likewise, as another user noted, the details of categories.yml aren't mentioned and just seem to confuse the matter as you don't appear to use it in your reference code. You may want to omit the latter bit, or make it a footnote.--James #24182: You might want to make mention of looking at the code for this test section. You tend to be very brief in your explanation and tend to leave ...more...
|
P4.0
22-Feb-06
|
|
| 140 |
|
#24315: Following the book, the create.sql creates MyISAM tables in MySQL by default. To change these later, use:
ALTER TABLE depot_test.products ENGINE=InnoDB;
or you can add ENGINE=InnoDB just before the semicolons in the create.sql CREATE TABLE statements.--Rufus #24315: Following the book, the create.sql creates MyISAM tables in MySQL by default. To change these later, use:
ALTER TABLE depot_test.products E ...more...
|
P4.0
17-Mar-06
|
|
| 141 |
|
#24340: Maybe it helps someone: here is the correct code for test_read_with_fixture_variable:
def test_read_with_fixture_variable
assert_kind_of Product, @product
assert_equal products(:version_control_book).id, @product.id
assert_equal products(:version_control_book).title, @product.title
assert_equal products(:version_control_book).description, @product.description
assert_equal products(:version_control_book).image_url, @product.image_url
assert_equal products(:version_control_book).price, @product.price
assert_equal products(:version_control_book).date_available, @product.date_available
end #24340: Maybe it helps someone: here is the correct code for test_read_with_fixture_variable:
def test_read_with_fixture_variable
assert_kind_ ...more...
|
P4.0
21-Mar-06
|
|
| 141 |
|
#24444: If you are getting the error about @products being nil then set use_instantiated_fixtures = true in test/test_helper.rb.--Luca Spiller
|
P4.0
11-Apr-06
|
|
| 141 |
68 |
#23938: As a side bar it would have been nice to have been warned about strftime and how our database with empty or default 0000-00-00 00:00:00 values for date_available would cause the application to fail.
I'm new to ROR and Ruby so, sorry if this is a known / given.
--Hezekia McMurray #23938: As a side bar it would have been nice to have been warned about strftime and how our database with empty or default 0000-00-00 00:00:00 values ...more...
|
P1.0
11-Jan-06
|
|
| 141 |
|
#24295: New to RoR, so this might be the same as the erratum beginning "With the new testing rules, a good chunk ".
In the test_read_with_hash method, the line
vc_book = @products["version_control_book"]
fails because @products is nil, i.e. does not seem to have been filled in.
Similarly, in the test_read_with_fixture_variable method, the line
assert_equal @version_control_book.id, @product.id
fails because @version_control_book is nil.--David Hislop #24295: New to RoR, so this might be the same as the erratum beginning "With the new testing rules, a good chunk ".
In the test_read_with_hash method ...more...
|
P4.0
14-Mar-06
|
|
| 142 |
|
#23879: Figure 12.1 suggests the members of the @products hash are Product objects coming from the database, as @version_control_book is. This is misleading because the @products hash contains Fixtures. in particular with the former @product.data_available_before_type_cast is needed in the equals assertion, whereas in the latter @product.data_available works.--Xavier Noria #23879: Figure 12.1 suggests the members of the @products hash are Product objects coming from the database, as @version_control_book is. This is misl ...more...
|
P3.1
24-Dec-05
|
|
| 143 |
|
#23850: If you make a mistake in the yaml for the entry @future_proof_book, you won't be told if it doesn't exist and it will silently pass as it resolves to nil. I added:
unavailable_item = @future_proof_book
assert_not_nil unavailable_item
assert !items.include?(unavailable_item)
to catch that possibility.--Yan-Fa Li #23850: If you make a mistake in the yaml for the entry @future_proof_book, you won't be told if it doesn't exist and it will silently pass as it reso ...more...
|
P3.1
15-Dec-05
|
|
|
144 |
#24142: "... then paying his valid credit card..." -> "... then paying with his valid credit card ..."--Justin Johnson
|
P2.0
16-Feb-06
|
|
| 146 |
|
#24005: test_helper.rb looks (mostly) nothing like the example in the PDF.
It now looks like:
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'test_help'
class Test::Unit::TestCase
# Transactional fixtures accelerate your tests by wrapping each test method
# in a transaction that's rolled back on completion. This ensures that the
# test database remains unchanged so your fixtures don't have to be reloaded
# between every test method. Fewer database queries means faster tests.
#
# Read Mike Clark's excellent walkthrough at
# http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting
#
# Every Active Record database supports transactions except MyISAM tables
# in MySQL. Turn off transactional fixtures in this case; however, if you
# don't care one way or the other, switching from MyISAM to InnoDB tables
# is recommended.
self.use_transactional_fixtures = false
# Instantiated fixtures are slow, but give you @david where otherwise you
# would need people(:david). If you don't want to migrate your existing
# test cases which use the @david style and don't mind the speed hit (each
# instantiated fixtures translates to a database query per test method),
# then set this back to true.
self.use_instantiated_fixtures = true
# Add more helper methods to be used by all tests here...
end
--Dave Myron #24005: test_helper.rb looks (mostly) nothing like the example in the PDF.
It now looks like:
ENV["RAILS_ENV"] = "test"
require File.expand_pat ...more...
|
P4.0
31-Jan-06
|
|
|
147 |
#23885: test_helper.rb must be updated in order for the test_destroy method to be used if the MySQL database is using MyISAM tables (the default for CocoaMySQL). One must set "self.use_transactional_fixtures = false"--Parker McGee #23885: test_helper.rb must be updated in order for the test_destroy method to be used if the MySQL database is using MyISAM tables (the default for C ...more...
|
P3.0
27-Dec-05
|
|
|
148 |
#23887: Rails has recently, in 1.0, updated the way it handles fixtures. If you're having problems, see Mike Clark's weblog here: http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting--Parker McGee #23887: Rails has recently, in 1.0, updated the way it handles fixtures. If you're having problems, see Mike Clark's weblog here: http://clarkware.co ...more...
|
P3.0
28-Dec-05
|
|
|
148 |
#24022: The @products and @version_control_book instance variables are not available unless you set the 'use_instantiated_fixtures' attribute to true. This can be set in the TestCase class Rails creates for you.--Cathal #24022: The @products and @version_control_book instance variables are not available unless you set the 'use_instantiated_fixtures' attribute to true. ...more...
|
P3.0
03-Feb-06
|
|
|
148 |
#24561: when running test_read_with_hash omitting the before_type_cast suffix to the date assertion seems to allow the test to pass - including it causes a mismatch between the hashed fcture date and that called from test.database --laura herald #24561: when running test_read_with_hash omitting the before_type_cast suffix to the date assertion seems to allow the test to pass - including it cau ...more...
|
P4.0
01-May-06
|
|
|
151 |
#23261: Maybe I'm not quite understanding what Mike is saying (in the context of using a dynamic fixture to 'future-proof' the test of salable_items). He says "Perhaps we should refactor the salable_items() method to take a date as a parameter. That way we could unit test the salable_items() method simply by passing in a future date to the method...".
It would seem that instead of passing in a 'future' date. You'd want to send in a known, fixed, date that would be prior to the one in the fixture for the future-proof book.
I'm thinking it as salable_items AS OF a supplied date,
and typically it would be today's date in production, but could be fixed for tests.--Richard Jensen #23261: Maybe I'm not quite understanding what Mike is saying (in the context of using a dynamic fixture to 'future-proof' the test of salable_items). ...more...
|
P1.0
27-Sep-05
|
|
|
152 |
#28629: in your tests, you are testing the equality of ambiguous numbers (floats). The prices you chose for the fixtures just _happen_ to work, but other prices will cause this error:
1) Failure:
test_add_unique_products(CartTest) [test/unit/cart_test.rb:15]:
<#<BigDecimal:b74e84fc,'0.5988E2',8(16)>> expected but was
<59.88>.
use (for example)
assert_equal sprintf("%0.2f", (@version_control_book.price + @automation_book.price) ), sprintf("%0.2f", @cart.total_price)--Andrew Yates #28629: in your tests, you are testing the equality of ambiguous numbers (floats). The prices you chose for the fixtures just _happen_ to work, but ot ...more...
|
P3.0
19-Apr-07
|
|
| 156 - 159 |
|
#24080: The file examples for store_controller.rb thoughout this section contain arguments to the fixture() method that look like this.
fixtures :products, :orders.
Having both these fixtures referenced causes ActiveRecord::StatementInvalid: Mysql::Error: type errors to be raised when the test is run.
This appears to be the result of the fact that orders.yml at this point has not been modified, and contains the default generated values that Rails provides. The errors specifically mention that the orders table does not specify default values that the ActiveRecord tries to insert into this table using such assign statements as assert_equal 1, assigns(:items).size.
The addition of the necessary fixture information to oreders.yml is discussed at the end of this section, and unless I'm mistaken, has not been suggested before this.
Perhaps this will help others to trace this problem without wasting much time.--m gentzel #24080: The file examples for store_controller.rb thoughout this section contain arguments to the fixture() method that look like this.
fixtures :pro ...more...
|
P4.0
07-Feb-06
|
|
|
156 |
#24441: Book Version 2005-12-20. Running "ruby test/functional/login_controller_test.rb" produces error: "method 'before_destroy' for LoginController:Class (NoMethodError)". I comment out the "before_destroy dont_destroy_dave" line from login_controller.rb and I get the result specified in the book (the "302" error). Being new at ruby/rails (learning directly from this book) not sure how to fix this... (running 1.8.2 on XPPro)--Martin Crundall #24441: Book Version 2005-12-20. Running "ruby test/functional/login_controller_test.rb" produces error: "method 'before_destroy' for LoginController ...more...
|
P4.0
11-Apr-06
|
|
|
159 |
#24197: This may be a Ruby/Rails version problem (Ruby 1.8.2, Rails 1.0.0). The session array is problematic. I see examples with it as a global variable (your book) and as a session variable (e.g., Four Days on Rails). Confusing, but not your fault. However, on my version(s), session is not a global variable in the functional test code, it is a field of @request. This makes sense to me and my code runs.--Jeffrey L. Taylor #24197: This may be a Ruby/Rails version problem (Ruby 1.8.2, Rails 1.0.0). The session array is problematic. I see examples with it as a global var ...more...
|
P3.0
25-Feb-06
|
|
| 166 |
|
#27028: The listing of application.rb is inaccurate. It should include the following lines just after the class declaration:
# Pick a unique cookie name to distinguish our session data from others'
session :session_key => '_depot_session_id'
--Tom Pollard #27028: The listing of application.rb is inaccurate. It should include the following lines just after the class declaration:
# Pick a unique coo ...more...
|
P4.0
23-Feb-07
|
|
| 169 |
|
#24297: File 121 online (http://media.pragprog.com/titles/rails/code/depot_testing/test/performance/order_test.rb) doesn't quite match the code on the page, nor the code from the zip file I downloaded. I didn't diff it, but at least the elapsedSeconds test is different (8.0 in the book and zip, 3.0 in the online file, probably as it once was in the book?)--David Hislop #24297: File 121 online (http://media.pragprog.com/titles/rails/code/depot_testing/test/performance/order_test.rb) doesn't quite match the code on the ...more...
|
P4.0
15-Mar-06
|
|
| 169 |
|
#24298: When running the performance test it fails with a MySQL foreign key constraint violation. Examining the test log file, it's because the first save_order after the add_to_cart generated by the code "get :add_to_cart, :id => products(:version_control_book).id" created a single line item associated with the first order. Knowing at this stage of the book how to fix situations like this by ordering the deletes after a test would be nice!--David Hislop #24298: When running the performance test it fails with a MySQL foreign key constraint violation. Examining the test log file, it's because the first ...more...
|
P4.0
15-Mar-06
|
|
| 170 |
|
#24347: The use of transactional fixtures is already standard in my version of Rails (set in test_helper.rb).--Juergen
|
P4.0
21-Mar-06
|
|
| 170 |
|
#25446: h
|
P4.0
14-Jul-06
|
|
|
176 |
#24151: Running the code listed for File 121 on Page 176 of the book (12.7 Performance Testing) produced an integrity constraint violation error from MySQL caused by the Order.delete_all statement, which attempts to deletes orders which are tied to LineItems.
Modifying the fk_items_order constraint (create.sql, file 37/106, page 102/502) to include an ON DELETE CASCADE clause resolves the problem, by removing the line item record when deleting the associated order.
ALTER TABLE line_items DROP FOREIGN KEY fk_items_order;
ALTER TABLE line_items
ADD CONSTRAINT fk_items_order FOREIGN KEY (order_id) REFERENCES orders(id) ON DELETE CASCADE
I did use phpMyAdmin to create the tables and constraints, but going over it, I'm not sure why it would have worked for you guys, unless MySQL prior to 4.12 had default different behavior.--Nathan Youngman #24151: Running the code listed for File 121 on Page 176 of the book (12.7 Performance Testing) produced an integrity constraint violation error from ...more...
|
P3.0
17-Feb-06
|
|
| 183 |
|
#23936: Grouping controllers in modules: I have grouped controllers as described in this section using the command format:
myapp> ruby script/generate controller Admin::Book action1 action2 ...
FIles and directories were generated as described, however, a request formatted according to your example:
http://my.app/admin/book/edit/1234
results in an error "no action corresponds to book".--sharon #23936: Grouping controllers in modules: I have grouped controllers as described in this section using the command format:
myapp> ruby script/generat ...more...
|
P3.1
10-Jan-06
|
|
| 193 |
|
#25395: Logging In
Now that we have a user in the test database, let's see if we can log in as taht user. If we were using a browser....
----
taht should be that (This is from the beta excerpt of the testing chapter, in case you've already fixed this)--Orien Vandenbergh #25395: Logging In
Now that we have a user in the test database, let's see if we can log in as taht user. If we were using a browser....
----
...more...
|
P4.0
03-Jul-06
|
|
| 207 |
|
#24548: Order.find_on_page(page_num, page_size)
the above function defined should probably be more like,
def Order.find_on_page(page_num,page_size)
find(:all, :order => 'id', :limit => page_size, :offset => (page_num-1)*page_size)
end
note: (page_num-1)*page_size is the change--Mike Nelson #24548: Order.find_on_page(page_num, page_size)
the above function defined should probably be more like,
def Order.find_on_page(page_num,page_si ...more...
|
P4.0
27-Apr-06
|
|
| 209 |
|
#23966: To be a little more consistent, I think the line
order = Order.find_all_by_email(params['email'])
should be "orders = .... " to match the other find_all examples. #23966: To be a little more consistent, I think the line
order = Order.find_all_by_email(params['email'])
should be "orders = .... " to match t ...more...
|
P4.0
19-Jan-06
|
|
| 212 |
|
#23876: <blockquote><code>result = Product.update_all("price = 1.1*price", "title like '%Java%'") </code></blockquote>
It would have been useful if you showed the usage of like statements when you were explaining find() too. It isn't too hard to muck around and figure out, but would be a lot clearer if explicitly shown.--UltraBob #23876: <blockquote><code>result = Product.update_all("price = 1.1*price", "title like '%Java%'") </code></blockquote>
It would have been useful if ...more...
|
P3.1
23-Dec-05
|
|
| 213 |
222 |
#23948: In the bit about save vs. save! when it comes to callbacks in there too it doesn't work exactly like that either :-( Went digging and found http://dev.rubyonrails.org/ticket/1861 where they talk about it some more. --Chris Nolan.ca #23948: In the bit about save vs. save! when it comes to callbacks in there too it doesn't work exactly like that either :-( Went digging and found h ...more...
|
P4.0
17-Jan-06
|
|
| 221 |
|
#24423: With regard to assigning a new object to a has_one relationship, the text suggests the following code:
invoice = Invoice.new
# fill in the invoice
invoice.save!
an_order.invoice = invoice
When the invoice row is saved, it does not yet have a foreign key value for the order table--wouldn't this cause the SQL INSERT to be followed by an UPDATE to add the foreign key? In addition to being inefficient, what if the update fails and no error is generated? It would seem you are in the same boat so you are no better off (aside from the fact that an update is generally less likely to fail than an insert). Would a transaction help to force an error to be generated?
Also, if the invoice table does not allow a null |