Forum: Ruby on Rails Remove validation for a property

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

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
   end

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

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

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.


Regards,

Manuel
This topic is locked and can not be replied to.