我试图在Spree 1.3上的checkout/payment
期间覆盖以下错误消息
当用户忘记输入信用卡号,月份或cvv时,会显示以下消息:
Payments source is invalid
module Spree
class CreditCard < ActiveRecord::Base
validates :month, :year, :numericality => { :only_integer => true }
validates :number, :presence => true, :unless => :has_payment_profile?, :on => :create
validates :verification_value, :presence => true, :unless => :has_payment_profile?, :on => :create
上面创建的验证是发送此错误消息,我想覆盖,有一些更有用的东西,例如:Please check the credit card information entered.
有人知道在验证未通过时如何覆盖创建自定义错误消息。
提前谢谢你。
答案 0 :(得分:1)
试一试
module Spree
class CreditCard < ActiveRecord::Base
validates :verification_value, :presence => true, :unless => :has_payment_profile?, :on => :create,
message: "%{value} is reserved." }
end