新手问题 mongoid 中 validate 跟 before_validation 在使用上有什么特别的嘛

luffycn · November 13, 2014 · 920 hits
class Product
  include Mongoid::Document

  validate :check_scope

  def check_scope
    errors.add(:base, 'ddd')
  end
end

check_scope 如果直接返回 false, 或者 errors.add Product.create 无论如何都会通过

No Reply at the moment.
You need to Sign in before reply, if you don't have an account, please Sign up first.