lib/couch_potato/validation.rb in couch_potato-1.7.1 vs lib/couch_potato/validation.rb in couch_potato-1.9.0
- old
+ new
@@ -1,12 +1,20 @@
require 'active_model'
require 'active_model/translation'
module CouchPotato
module Validation
+ module ValidationContext
+ def valid?(context = nil)
+ context ||= new? ? :create : :update
+ super context
+ end
+ end
+
def self.included(base) #:nodoc:
base.send :include, ::ActiveModel::Validations
base.send :include, ::ActiveModel::Validations::Callbacks
+ base.send :include, ValidationContext
end
end
end
# provide same interface to errors object as in Validatable