Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7629197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:46:25+00:00 2026-05-31T05:46:25+00:00

I am under: Rails 3.0.9 Devise 1.4.7 jquery-ujs What have I done?… 1) I

  • 0

I am under:

Rails 3.0.9
Devise 1.4.7
jquery-ujs

What have I done?…
1) I have set up the sign-in form with data-remote=”true”.
2) I have set up the sign-in jquery handlers:

('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<ul>";

      for ( error in errors ) {
        errorText += "<li>" + error + ': ' + errors[error] + "</li> ";
      }

      errorText += "</ul>";

      // Insert error list into form
      $form.find('div.validation-error').html(errorText);
    });

3) I have redefined the session controller like this:

  def create
    resource = warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#failure")
    sign_in(resource_name, resource)
    return render :json => { :success => true, :content => current_user.email }
  end

  def failure
    return render:json => {:success => false, :errors => ["Login failed."]}
  end

4) I have set my the route.rb file:

devise_for :users, :controllers => {:sessions => "sessions"}

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 return render:json => {:success => false, :errors => ////email or password is wrong////}

Proble is: :recall doesn’t work. It looks like that Warden.authenticate! doesn’t see my failure method

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T05:46:27+00:00Added an answer on May 31, 2026 at 5:46 am

    The solutions was very simple )
    I have to set in config/initializers/devise.rb:

    config.http_authenticatable_on_xhr = false
    config.navigational_formats = [:html, :json]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a fairly simple Rails remote form in HAML in a partial under
I'm using the devise authentication plugin under rails 3. At the moment, I have
I'm using the devise authentication plugin under rails 3. At the moment, I have
Does Ruby on Rails have a way to use jQuery rather than Prototype under-the-bonnet
I am under Rails 3.0.9. I have the route: get 'account/index' There are such
I have a rake task which runs mailman under the rails environment. I'd like
I'm under rails 3.2.1 and I have a problem by show the localized month
Working with a relatively large data set I have a situation where I need
I am learning rails by following the Rails Tutorial under Ubuntu. I have been
I've set up Rails on Ubuntu 10 under VirtualBox. I've managed to configure pretty

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.