我有如下模型客户付款,
class Customerpayment < ActiveRecord::Base
#validation
validates :amount , numericality: { greater_than_or_equal_to: 0 }
validates :amount , presence: true
validates :date , presence: true
validates_each :amount do |record, attr, value|
record.errors.add(attr, I18n.t(:invalid_paid)) if !valid_paid_amount(record , value)
end
end
- 问题是之前的验证 validates_each :amount
工作validates :amount , presence: true
,我希望最后一个工作,任何帮助请先validation validates :amount , presence: true
工作