conflicts with the migration add_test_data obj.create method setting
:price => 28.56
You might need to update your beta book, because I can't find any
reference to :only_integer on that page. I'm looking at version B1.16.
No error is produced in log/development.log that indicates why the test
data is not being entered btw.
Accurate error output would have vastly decreased the time it took me
to locate this problem as a rails/ruby newbie.
Ah, but think how much you've learned in figuring out this problem by
yourself!
Seriously, though, validation failures aren't reported as errors in the
log because they aren't errors. It's a part of the normal application
flow: someone fills out a form incorrectly, the validation fails, and
you redisplay the form. For this reason, the common methods (.save,
.create) don't raise an exception if the record could not be saved due
to validation failures.
If it makes sense in your application, you can use the alternative
forms .save! and .create!, which *will* raise an exception if the
saving fails.
So in this migration, yes, it might have been better to write the
Product.create() lines so that an exception is raised if the creation
of the test data failed. That way you would have been alerted to the
problem. But I don't think it's a fundamental problem with Rails.
I don't believe the book says that: the price field has been a decimal for a long time time (only the first couple of versions of the beta book had an integer price--after that the core team introduced support for decimal types and I changed the example to use them).
I suggest you regenerate your PDF to get the latest description (I'd have done this for you, but I can't find an order under your e-mail address).