Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Open Source > BOOK: Beginning Ruby on Rails
|
BOOK: Beginning Ruby on Rails
This is the forum to discuss the Wrox book Beginning Ruby on Rails by Steve Holzner Ph.D.; ISBN: 9780470069158
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Ruby on Rails section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 16th, 2007, 08:14 PM
Registered User
 
Join Date: Jan 2007
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default ch 8 "validate against inclusion in a list"

On p, 235 of "Beginning Ruby on Rails" the "Validating against Inclusion in a List" Try It Out example is not working for me. I created the database and table correctly and even deleted and recreated them to be sure. I also properly edited and saved the field.rb file according to the book's instructions as well as the _form.rhtml file. When I start the WEBrick Server and access http://localhost:3000/manage I am able to click on the link to go to the view to add a new field, but no matter what number I enter whether it is within the 1 to 99 range or not, I receive the error that "data is out of bounds" which I should only receive if I enter a number less than 1 or greater than 99. Any assistance in getting this to work would be great. Thanks.
 
Old January 16th, 2007, 08:29 PM
Registered User
 
Join Date: Jan 2007
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The following example "validates_exclusion_of" doesn't work either. Instead of not allowing anything like the previous example, it allows anything and doesn't exclude any numbers.
 
Old February 13th, 2007, 12:42 PM
Registered User
 
Join Date: Feb 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The author already detected this error p235
(see the errata before posting, if you can).

The problem is that you try to compare a string input with a numeric.
Your should write '1'..'99', not 1..99, in the test.

Cheers !


 
Old February 13th, 2007, 01:47 PM
Registered User
 
Join Date: Jan 2007
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Demitton, thanks. I was the one who pointed out that error and they added it after. The other way to fix the problem is to change the type that the database record expects. Then you can use integers instead of strings.
 
Old June 28th, 2010, 09:07 PM
Registered User
 
Join Date: Jun 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Neither the book code nor the errata code works. The errata code never detects an error (using InstantRails 1.7 so there are no version issues). Any suggestions?
 
Old July 20th, 2010, 07:02 PM
Registered User
 
Join Date: Jun 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

What works in Instant Rails 1.7 is

"1..99"

The '1'..'99' listed above does not work.





Similar Threads
Thread Thread Starter Forum Replies Last Post
conditional inclusion of a namespace suman9730 General .NET 1 September 6th, 2006 03:19 AM
fill dropdown list with items when parent list isaac_cm Pro PHP 1 July 10th, 2006 05:41 AM
List tablesname from database & list databasename ittorget MySQL 3 September 10th, 2005 03:06 AM
Ch. 4 & Ch. 12 athena BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 July 23rd, 2004 10:54 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.