我试图路径 ActiveRecord 模型验证 -
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 strict_validate_issue
if !due_date
errors.add :due_date, :due_date_empty
end
unstrict_validate_issue
end
end
end
Issue.send :include, IssuePath
但它抛出了一个错误 NameError: undefined method unstrict_validate_issue' for class
Issue (call 'Issue.connection' to建立连接)'。