Forum: Ruby on Rails How to disable validation during a migration

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Fb1a6916e06f221b5b53a6665f9858eb?d=identicon&s=25 Mikel (Guest)
on 2007-07-02 06:52
(Received via mailing list)
I have a migration I am doing which involves a change in column name
that my model uses for validation.

Part of the migration is changing data in that column, which would
fail the validation, but will pass the new validation.

Is there anyway I can "turn off validation" inside the migration for
the duration of the migration?

I have worked around it... but would be good to know for future ref.

Thanks

Mikel
807e34b31d5463a9ac05d41458a9e537?d=identicon&s=25 Al Evans (al-evans)
on 2007-07-03 00:27
Mikel wrote:
> I have a migration I am doing which involves a change in column name
> that my model uses for validation.
>
> Part of the migration is changing data in that column, which would
> fail the validation, but will pass the new validation.
>
> Is there anyway I can "turn off validation" inside the migration for
> the duration of the migration?
>
> I have worked around it... but would be good to know for future ref.

I'm not sure I understand the question, but you can always say...

whatever.save_with_validation(false)

...to skip validation.

--Al Evans
This topic is locked and can not be replied to.