Change the default error message with simple_form

I am unable to change the default error message from a simple form, I tried to edit the simple form locale file, but it seems to be ignored

Here is my locale file:

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

But I still get "Please view the problems below:"

Does anyone know what I'm doing wrong?

+5
source share
1 answer

Change :default_messageto:your_model_name

As you can see in the source , the method error_notificationuses translate_error_notificationto get the translation from the YAML file.

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

For the usermodel lookupscontains:

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

The translation may differ for each object, so this transaction is called:

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

Vote if that helps;)

+1
source

All Articles