作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我在模型数据包上出现错误时,我总是看到第一行(英文=未翻译):
1 error prohibited this packet from being saved:
Naam Gelieve het veld Naam in te vullen!
nl.yml
中有以下内容
nl:
activemodel:
errors:
template:
header:
one: "1 fout voorkwam dat dit %{model} kon bewaard worden"
other: "%{count} fouten voorkwamen dat deze %{model} kon bewaard worden"
body: "Er waren problemen met de volgende velden:"
errors:
template:
body: "Controleer alstublieft de volgende velden:"
header:
one: "Kon dit {{model}} object niet opslaan: 1 fout."
other: "Kon dit {{model}} niet opslaan: {{count}} fouten."
activerecord:
errors:
template:
header:
one: "1 fout voorkwam dat dit %{model} kon bewaard worden"
other: "%{count} fouten voorkwamen dat deze %{model} kon bewaard worden"
body: "Er waren problemen met de volgende velden:"
messages:
blank: Gelieve het veld %{attribute} in te vullen!
models:
survey: test
packet: woordenlijst
user: gebruiker
attributes:
survey:
name: Naam
最佳答案
哦!找到了!愚蠢的我!
忘了在 rails 3 中你不再使用 error_messages_for
,所以在我的脚手架 View 代码中有以下代码:
= form_for @packet do |f|
-if @packet.errors.any?
#errorExplanation
%h2= "#{pluralize(@packet.errors.count, "error")} prohibited this packet from being saved:"
-if @packet.errors.any?
#errorExplanation
%h2
- if @packet.errors.count == 1
= t 'activerecord.errors.template.header.one', :model => @packet.class.human_name
- else
= t 'activerecord.errors.template.header.other', :model => @packet.class.human_name, :count => @packet.errors.count
%b= t 'activerecord.errors.template.body'
%ul
- @packet.errors.full_messages.each do |msg|
%li= msg
关于internationalization - 导轨 I18n : can't override "1 error prohibited this packet from being saved:",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3822199/
我是一名优秀的程序员,十分优秀!