11

Vì vậy, bạn có thể thay đổi một thông báo lỗi trong en.yml với một cái gì đó như sau:Rails i18n định dạng xác nhận lỗi cụ thể

en: 
    activerecord: 
    errors: 
     models: 
     foo: 
      attributes: 
      amount: 
       greater_than_or_equal_to: "Custom GTOE error message." 

Tuy nhiên, điều này sẽ nói như sau:

Amount Custom GTOE error message. 

tôi biết Tôi có thể xóa nó trên toàn cầu với:

en: 
    activerecord: 
    errors: 
     format: "%{message}" 

Nhưng tôi có thể khắc phục %{attribute} chỉ để xác thực này không?

Cảm ơn!

+0

thấy https://github.com/rails/rails/pull/7369, vẫn mở dù –

+1

Cập nhật đến: https://github.com/rails/rails/pull/14260 – juanitofatas

Trả lời

-3
validates :amount, :numericality => { :greater_than_or_equal_to => YOUR_VALUE, :message => YOUR_ERROR_MESSAGE } 
+0

không đúng! Vẫn sẽ có "% {attribute} YOUR_ERROR_MESSAGE" – andrewpthorp

Các vấn đề liên quan