Page 87. Suggested validation parameter of: validates_numericality_of :price, :only_integer => true conflicts with the migration add_test_data obj.create method setting :price => 28.56 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. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
krunk wrote:> Page 87. > > Suggested validation parameter of: > > validates_numericality_of :price, :only_integer => true > > conflicts with the migration add_test_data obj.create method setting > :price => 28.56You 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. Chris --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Nov 6, 2006, at 12:01 AM, krunk wrote:> Suggested validation parameter of: > > validates_numericality_of :price, :only_integer => trueI 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). Regards Dave Thomas --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---