Forum: Ruby on Rails Remove validation for a property

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.
Manuel H. (Guest)
on 2006-04-23 01:43
(Received via mailing list)

Does anyone here know a way who I could remove the validation for a
model's property? For example, I would like to have in one file:

   class A < ActiveRecord::Base
     validates_uniqueness :title

And in another file I want to override or rather remove the validation:

   class A < ActiveRecord::Base
     # somehow stop validating :title for uniqueness

The purpose of this? Well, I could provide a model "A" in a plugin or
component and change its behaviour in my application.

This comes in handy, for example, if you want to provide a default
format for user names (very restrictive, maybe only :alnum:) in your
application, however, you want to allow spaces.


This topic is locked and can not be replied to.