0
如何返回空欄位的自定義消息在軌道中?鐵路返回自定義空白字段錯誤消息
validates_presence_of :name, :description, :message => "Please fill in the required fields."
如果兩個都爲空,則返回錯誤消息的兩個實例。我只是想讓它返回一次。
這可能嗎?
如何返回空欄位的自定義消息在軌道中?鐵路返回自定義空白字段錯誤消息
validates_presence_of :name, :description, :message => "Please fill in the required fields."
如果兩個都爲空,則返回錯誤消息的兩個實例。我只是想讓它返回一次。
這可能嗎?
現在,設置人性化的名稱和自定義錯誤信息的接受方式是使用當地人(For more reference click here)
# config/locales/en.yml
en:
activerecord:
attributes:
user:
email: "E-mail address"
errors:
models:
user:
attributes:
email:
blank: "is required"
現在人性化的名稱和「電子郵件」屬性的存在驗證消息已經改變。
可以爲特定模型+屬性,模型,屬性或全局設置驗證消息。