Rails: translate ActiveRecord error template headers for a single model
I'm trying to rename the authlogic error messages in a Rails 3 app.
The general format I found out working in Rails 3:
de:
errors:
template:
header:
one: "Konnte {{model}} nicht speichern: ein Fehler."
other: "Konnte {{model}} nicht开发者_JAVA百科 speichern: {{count}} Fehler."
body: "Bitte überprüfen Sie die folgenden Felder:
But I want to change this for the authlogic user session model (and only for this one) because when the Login fails, the message "Could not save user session" does not make very much sense.
How can I do that?
I had the same problem and I fixed it this way:
Put in your view (like: _form.html.erb)
<div id="error_explanation">
<h2><%= I18n.t('activerecord.errors.template.header', :count => @user.errors.size, :model => @user.class) %></h2>
<h4><%= I18n.t('activerecord.errors.template.body', :count => @user.errors.size) %></h4>
It should work fine!
精彩评论