David Jaquay
2007-Jul-11 16:54 UTC
Model validation causing rake db:migrate to fail silently
I added a migration that adds data with a model class, calling create(). Validation in the model class fails, so the rows aren''t being added to the database. But when I run ''rake db:migrate'', it says nothing about the failures, causing me frustration when rake looks like it worked, but the data doesn''t get loaded. I''m new to rails; is there something I''m missing about getting rake (or a migration, at least) to display its errors the same way that rails does (at least via the scaffold)? Thanks, Dave -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Chris Hall
2007-Jul-11 17:01 UTC
Re: Model validation causing rake db:migrate to fail silently
try using create! which will raise an exception if the record is invalid. On 7/11/07, David Jaquay <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > I added a migration that adds data with a model class, calling create(). > Validation in the model class fails, so the rows aren''t being added to > the database. But when I run ''rake db:migrate'', it says nothing about > the failures, causing me frustration when rake looks like it worked, but > the data doesn''t get loaded. > > I''m new to rails; is there something I''m missing about getting rake (or > a migration, at least) to display its errors the same way that rails > does (at least via the scaffold)? > > Thanks, > Dave > > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
David Jaquay
2007-Jul-11 17:29 UTC
Re: Model validation causing rake db:migrate to fail silentl
Chris Hall wrote:> try using create! which will raise an exception if the record is > invalid.Awesome, that''s exactly what I want to see. Thanks, Dave -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---