Search code examples
ruby-on-rails-3simple-form

Simple_form - How to add field name to error messages?


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".


Solution

  • You can set the error message in the model:

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