我的模型客户付款方式如下,
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
先工作