title: Rails 3 Devise Ajax login Catching Error Message
body: <p>I am under:<br> 
  Rails 3.0.9<br>
  Devise 1.4.7<br>
  jquery-ujs</p>
  
  <p>What have I done?...<br>
  1) I have set up the sign-in form with data-remote="true".<br>
  2) I have set up the sign-in jquery handlers:  </p>
  
  <pre><code>('form#user-reg-form')
      .bind("ajax:beforeSend", function(evt, xhr, settings){
      })
      .bind("ajax:success", function(evt, data, status, xhr){
        $('#comments').append(xhr.responseText);
  
      })
      .bind('ajax:complete', function(evt, xhr, status){
      })
      .bind("ajax:error", function(evt, xhr, status, error){
        try {
          errors = $.parseJSON(xhr.responseText);
        } catch(err) {
          errors = {message: "Please reload the page and try again"};
        }
        errorText = "There were errors with the submission: \n&lt;ul&gt;";
  
        for ( error in errors ) {
          errorText += "&lt;li&gt;" + error + ': ' + errors[error] + "&lt;/li&gt; ";
        }
  
        errorText += "&lt;/ul&gt;";
  
        // Insert error list into form
        $form.find('div.validation-error').html(errorText);
      });
  </code></pre>
  
  <p>3) I have redefined the session controller like this:  </p>
  
  <pre><code>  def create
      resource = warden.authenticate!(:scope =&gt; resource_name, :recall =&gt; "#{controller_path}#failure")
      sign_in(resource_name, resource)
      return render :json =&gt; { :success =&gt; true, :content =&gt; current_user.email }
    end
  
    def failure
      return render:json =&gt; {:success =&gt; false, :errors =&gt; ["Login failed."]}
    end
  </code></pre>
  
  <p>4) I have set my the route.rb file: </p>
  
  <pre><code>devise_for :users, :controllers =&gt; {:sessions =&gt; "sessions"}
  </code></pre>
  
  <p>Everything works...but when I pass wrong email or password I have uncaught message from the User model (maybe from Devise) "email or password is wrong". But I want to catch this message and put it in json object something like this <strong>return render:json => {:success => false, :errors => ////email or password is wrong////}</strong></p>
  
  <p>Proble is: <strong>:recall doesn't work. It looks like that Warden.authenticate! doesn't see my failure method</strong></p>