Search code examples
htmlruby-on-railsrubyformsdevise

Error prohibited this user from being saved:


I've been having an issue that I can't seem to fix

3 errors prohibited this user from being saved:

  • Email can't be blank
  • Password confirmation doesn't match Password
  • Password is too short (minimum is 8 characters)

I can't figure out how to get rid of the 3 error prohibited this user from being saved: All I want to display is the errors in bullets. Any ideas on how to go along with this? I'm using Devise, by the way.


Solution

  • I can't figure out how to get rid of the 3 error prohibited this user from being saved

    We override the devise helper to give us ultimate control over the errors we wish to show. Here is a helpful resource which shows you how to achieve this

    --

    Helper

    As per the answer by Buck Doyle & the attached resource, you may wish to do this:

    #app/helpers/devise_helper.rb
    module DeviseHelper
      def devise_error_messages!
         resource.errors.full_messages.map { |msg| content_tag(:li, msg) }.join
      end
    end
    

    This will allow you to change your devise views to include the devise_error_messages! method:

    #app/views/devise/registrations/new.html.erb
    <%= devise_error_messages! %>