6

デフォルトのエラーメッセージを単純なフォームから変更できません。単純なフォームのロケールファイルを編集しようとしましたが、無視されているようです。

これが私のロケールファイルです:

#config/locales/simple_form.en.yml
en:
  simple_form:
    error_notification:
      default_message: "A custom message:"

それでも、「以下の問題を確認してください」というメッセージが表示されます。

誰かが私が間違っていることを知っていますか?

4

1 に答える 1

1

に変更:default_messageします:your_model_name

sourceでわかるように、error_notificationメソッドはtranslate_error_notificationYAML ファイルから翻訳を取得するために使用します。

def translate_error_notification
  lookups = []
  lookups << :"#{object_name}"
  lookups << :default_message
  lookups << "Please review the problems below:"
  I18n.t(lookups.shift, scope: :"simple_form.error_notification", default: lookups)
end

userモデルのlookups内容:

lookups == [:user, :default_messge, "Please review the problems below:] 

変換はオブジェクトごとに異なる可能性があるため、このトランザクションが呼び出されます。

#config/locales/simple_form.en.yml
en:
  simple_form:
    error_notification:
      user: "A custom message:"

それが役立つかどうか投票してください;)

于 2014-06-09T23:43:55.303 に答える