0

我試圖在Rails 3應用程序中重命名authlogic錯誤消息。Rails:爲單個模型翻譯ActiveRecord錯誤模板標頭

的通用格式,我發現在Rails 3的工作:

de: 
    errors: 
    template: 
     header: 
     one: "Konnte {{model}} nicht speichern: ein Fehler." 
     other: "Konnte {{model}} nicht speichern: {{count}} Fehler." 
     body: "Bitte überprüfen Sie die folgenden Felder: 

但我想改變這個爲authlogic用戶會話模型(且僅此一個),因爲當登錄失敗,消息「無法保存用戶會話「沒有多大意義。

我該怎麼做?

+0

壞消息,但rails3刪除了在rails2中使用這些錯誤消息的幫助程序。它們可以在插件中使用,但很可能您要更改的錯誤消息是硬編碼的或可在其他位置配置。 – 2010-06-20 23:28:53

回答

3

我有同樣的問題,我固定它是這樣的:
把你的觀點(如:_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> 

應該做工精細!