small medium large xlarge

13 Feb 2008, 14:24
Ethan Garofolo (2 posts)

My book version on the copyright page states P3.0, which I can’t find on the errata page on the site. I got it off of Amazon, so I hope they didn’t get me the Special Bootlegged Edition.

Anyway, I’m having fits with the first bits of code on using AWS. I know that AWS is falling out of favor with the Core Team, but I still like to be aware of what’s out there.

Here’s the problem: I type in the code exactly as it is in the book (Ch. 25’s code is not included in the downloadable code, incidentally), and when I execute the first test, again following the book, I get an error that :decimal is not a valid type. Now, I did some looking into this, and in signature_types.rb of the AWS gem code, there is the method canonical_type_name. There is no case for :decimal, so it falls through to the else on the case statement. Just for giggles, I added :decimal to the :int, :integer… case. This seemed to fix the issue, but sue me if that solution felt extremely hacky.

I’m guessing the issue is with the type that my DB (MySQL 5 or so) is using to represent the price column of the products table (decimal). I could change that to float, I suppose, but I arrived at decimal by following the book. Perhaps it would be good to change that or make an errata? Would changing from decimal to float hose the application? I know it isn’t a “real” application, depot, but you know, let’s say I did make a real e-commerce application. Would using floats for prices vs. decimals cause me problems?

Thanks to anyone who replies.

13 Feb 2008, 14:48
Ethan Garofolo (2 posts)

But of course, placing the decimal where I did doesn’t really work because the prices aren’t integers. Would a better solution be to just store prices as cents rather than dollars and cents? Then an integer would work for the type.

You must be logged in to comment