简体   繁体   中英

How can i custom devise_error_messages?

I want to show this:

  • Email can not be blank
  • Password can not be blank

But i see:

Email can not be blank Password can not be blank

This is Devise_Helper:

module DeviseHelper
  def devise_error_messages!
    return '' if resource.errors.empty?

    messages = resource.errors.full_messages.map { |msg| content_tag(:li, msg) }.join
    html = <<-HTML

    <div class="alert alert-error alert-danger"> <button type="button"
    class="close" data-dismiss="alert">×</button>
      #{messages}
    </div>
    HTML

    html.html_safe
  end
end

You surely have to change the .yml files settled in:

config/locales/devise.en.yml

Each error has a key and a value .Just change the value you wanted to see and if you don't have the file you can either generate it by yourself or clone it from here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM