Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm trying to figure this out myself. I just found this issue logged on Github <a href="https://github.com/plataformatec/devise/issues/issue/504/#comment_574788" rel="noreferrer">https://github.com/plataformatec/devise/issues/issue/504/#comment_574788</a></p> <p>Jose is saying that <code>devise_error_messsages!</code> method is just a <em>stub</em> (though it contains implementation) and that we're supposed to override/replace it. It would have been nice if this was pointed out somewhere in the wiki, which is why i guess there are a few people like us that have been guessing.</p> <p>So I'm going to try reopening the module and redefine the method, effectively overriding the default implementation. I'll let you know how it goes.</p> <h2>Update</h2> <p>Yep, that works. I created <code>app/helpers/devise_helper.rb</code> and overrode it like so:</p> <pre><code>module DeviseHelper def devise_error_messages! 'KABOOM!' end end </code></pre> <p>So knowing this, I can modify the method to display error messages the way I want it to.</p> <p>To help you solve your original problem: Here's the original <a href="https://github.com/plataformatec/devise/blob/master/app/helpers/devise_helper.rb" rel="noreferrer"><code>devise_helper.rb</code> on Github</a>. Take a look at how the error messages are being traversed:</p> <pre><code>messages = resource.errors.full_messages.map { |msg| content_tag(:li, msg) }.join </code></pre> <p>That should help you get started. :)</p> <h2>Another update</h2> <p>The <code>resource</code> object is actually the model that is being used by devise (go figure). </p> <pre><code>resource.class #=&gt; User resource.errors.class #=&gt; ActiveModel::Error </code></pre> <p>It also appears to be defined in a higher scope (probably coming from the controller), so it can be accessed in a variety of places.</p> <p>Anywhere in your Helper</p> <pre><code>module DeviseHelper def devise_error_messages1! resource.errors.full_messages.map { |msg| content_tag(:li, msg) }.join end def devise_error_messages2! resource.errors.full_messages.map { |msg| content_tag(:p, msg) }.join end end </code></pre> <p>Your View</p> <pre><code>&lt;div&gt;&lt;%= resource.errors.inspect %&gt;&lt;/div&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload