1
votes

I have tweaked the bootstrap wrapper so that now I display all inline errors as a block above the simple_form field.

The form is a registration Devise form, specifically from the rails-prelaunch-signup composer app. How can I include the name of the field in the error message?

At the moment I am getting "isn't valid" or "can't be blank", however I would like something like "Email can't be blank".

2

2 Answers

4
votes

Simpleform refers to rails localization if no error message is set in the model. So, if you want to add the attributes name to each error message, you could add something like this in your locale-file:

en:
  errors:
    messages:
      blank: "%{attribute} can't be blank"
      invalid: "%{attribute} isn't valid" 

Where %{attribute} is the placeholder where the fields name will be inserted.

1
votes

You can set the error message in the model:

validates :email, presence: { error_message: "Email can't be blank" }