Вместо strict_validate_issue
определите unstrict_validate_issue
метод и вызовите strict_validate_issue
внутри него.
require_dependency "issue"
module IssuePath
def self.included(base) # :nodoc:
base.send(:include, InstanceMethods)
base.class_eval do
alias_method :strict_validate_issue, :validate_issue
alias_method :validate_issue, :unstrict_validate_issue
end
end
module ClassMethods
end
module InstanceMethods
def unstrict_validate_issue
if due_date.blank?
errors.add :due_date, :due_date_empty
end
strict_validate_issue
end
end
end
Issue.send :include, IssuePath
Вы можете даже сделать его короче:
require_dependency "issue"
module IssuePath
extend ActiveSupport::Concern
included do
alias_method :strict_validate_issue, :validate_issue
alias_method :validate_issue, :unstrict_validate_issue
end
def unstrict_validate_issue
if due_date.blank?
errors.add :due_date, :due_date_empty
end
strict_validate_issue
end
end
Issue.send :include, IssuePath