Forum: Ruby on Rails Disable validations

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Rm R. (Guest)
on 2007-02-26 23:06
If a model has validations defined on it and in certain cases I don't
want some validations to be done then how can I disable the validations
that I don' want to be done?

model.valid? will do all the validations but I wan't only some
validations to be done and others to be ignored.

Like a form for create may have some fields in model which can be left
blank, so they should not be validated. But in another form those fields
are present, and the fields which are not present on that screen will
cause validation to fail.

Luke I. (Guest)
on 2007-02-26 23:12
(Received via mailing list)
I'm not sure exactly what you're asking for here, but the standard way
only perform validations "sometimes" is by using the :if

validates_uniqueness_of :last_name, :if => :last_name_should_be_unique?

For more information, see:
This topic is locked and can not be replied to.