Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First reorganize this so that the <code>error_explanation</code> div exists on the page (so you can populate it with an error message... hide it with CSS if you need to)</p> <pre><code>&lt;div id="error_explanation"&gt; &lt;% if @user.errors.any? %&gt; &lt;h2&gt;&lt;%= pluralize(@user.errors.count, "error") %&gt; prohibited this user from being saved:&lt;/h2&gt; &lt;ul&gt; &lt;% @user.errors.full_messages.each do |msg| %&gt; &lt;li&gt;&lt;%= msg %&gt;&lt;/li&gt; &lt;% end %&gt; &lt;/ul&gt; &lt;% end %&gt; &lt;/div&gt; </code></pre> <p>Then you can add this bit of jQuery code to your existing <code>&lt;script&gt;</code> tag area:</p> <pre><code>// a method for parsing the JSON response handle_ajax_error = function(response) { try { var responseText = jQuery.parseJSON(response.responseText); } catch(e) { var responseText = null; } if (responseText !== null) { var responseMsg = responseText.error; } else { responseMsg = 'There was an unknown error or the request timed out. Please try again later'; } return responseMsg; } // callback for the ajax error on the #login form $('#login').live('ajax:error', function(data, xhr, response){ $('#error_explanation').html(handle_ajax_error(response)); }); </code></pre> <p>And then this assumes that you have something like this in your controller response for the error:</p> <pre><code>def create @user = User.create(params[:user]) if @user.save redirect_to user_path(@user) else render :json =&gt; { :error =&gt; @user.errors.full_messages.to_sentence }, :status =&gt; :unprocessable_entity end end </code></pre>
    singulars
    1. This table or related slice is empty.
    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. 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