默认的是支持自动选择错误提示语言的,向弄成全中文的可以这样:
在你的appliacation_help.rb中加入:
代码:
|
def error_messages_for(object_name, options = {})
options = options.symbolize_keys
object = instance_variable_get("@#{object_name}")
unless object.errors.empty?
error_lis = []
object.errors.each{ |key,msg| error_lis << content_tag("li", msg) }
content_tag("div",
content_tag(options[:header_tag] || "h2","发生了#{object.errors.count}个错误") +
content_tag("p", "错误来源于以下原因,请参考:") +
content_tag("ul", error_lis),
"id" => options[:id] || "errorExplanation", "class" => options[:class] || "errorExplanation"
)
end
end
|