Is there a way to drop a validation that was set in Rails plugin (or included module)?
Let’s say I have some model with module included in it:
class User < ActiveRecord::Base
include SomeModuleWithValidations
# How to cancel validates_presence_of :something here?
end
module SomeModuleWithValidations
def self.included(base)
base.class_eval do
validates_presence_of :something
end
end
end
My only idea so far was to do something like:
validates_presence_of :something, :if => Proc.new{1==2}
which would work, I think, but it isn’t particulary pretty.
See http://casperfabricius.com/site/2008/12/06/removing-rails-validations-with-metaprogramming/