Re: Model validation causing rake db:migrate to fail silently

Chris Hall
Wed, 11 Jul 2007 17:01:19 -0000

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/.
>
> >
>