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 6750995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:52:26+00:00 2026-05-26T12:52:26+00:00

Edit: I’ve solved the problem myself. If anyone has a better or more elegant

  • 0

Edit: I’ve solved the problem myself. If anyone has a better or more elegant solution, please post it here and I’ll select as the answer.

I’, using jQuery Mobile and mobile_fu to set up a mobile view for a rails3 application.

Devise is used for authentication, and it works perfectly in the desktop view.

My problem is that after a successfully login in the mobile view, the application redirects again to the sign_in form when it should redirect to the root page. The sign in is correct, and if i just reload the page, then the redirection to root is correctly made. The sequence is as follows:

I enter the root page URL in the mobile device
As the user is not authenticated, devise redirects to the sign in page
I enter the credentials and hit the login button
The login is performed correctly, but the application redirects to the sign in page again
Hit reload in the mobile device, and then the application redirects to the root page with the user correctly authenticated

I’ve followed this instructions to set up devise with mobile fu, but using a ‘mobile’ format instead of ‘iOS’ format:
https://github.com/plataformatec/devise/wiki/How-To%3a-Make-Devise-work-with-other-formats-like-mobile,-iphone-and-ipad-%28Rails-specific%29

Any help will be appreciated, i’ve been working on this issue a couple of days and it’s starting to drive me crazy :S
Thanks in advance!

I attach the request and response data both for mobile and desktop requests and responses when signing in:

Desktop login

Request

POST /users/sign_in HTTP/1.1 Host: localhost:3000 User-Agent:

Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:7.0.1) Gecko/20100101

Firefox/7.0.1 Accept:

text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8

Accept-Language: es-es,es;q=0.8,en-us;q=0.5,en;q=0.3 Accept-Encoding:

gzip, deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7

Connection: keep-alive Referer: http://localhost:3000/users/sign_in

Cookie:
_PMG_session=BAh7CkkiCmZsYXNoBjoGRUZJQzolQWN0aW9uRGlzcGF0Y2g6OkZsYXNoOjpGbGFzaEhhc2h7BjoKYWxlcnRJIkJOZWNlc2l0YXMgaW5pY2lhciBzZXNpw7NuIGNvbiB0dSBjdWVudGEgcGFyYSBwb2RlciBjb250aW51YXIuBjsAVAY6CkB1c2VkbzoIU2V0BjoKQGhhc2h7BjsHVEkiD3Nlc3Npb25faWQGOwBGIiViZjlkZDc4NzczMmFmMGViNjcyOWRkNzAxNWJhMzQ5YkkiEG1vYmlsZV92aWV3BjsARkZJIhN1c2VyX3JldHVybl90bwY7AEZJIgYvBjsARkkiEF9jc3JmX3Rva2VuBjsARkkiMWEyZW9oamFKT2tsWEZrbzZxc3lNenRhWTVEUk5XaHVUdm9iV3J3aFhFK1E9BjsARg%3D%3D–6623519d539757216a03d212a4e20647e8a5029c;
jstree_open=%231%2C%234%2C%235; jstree_load=

Response

HTTP/1.1 302 Found Location: http://localhost:3000/ Content-Type:

text/html; charset=utf-8 Cache-Control: no-cache X-UA-Compatible:

IE=Edge X-Runtime: 1.650766 Server: WEBrick/1.3.1

(Ruby/1.9.2/2011-02-18) Date: Mon, 31 Oct 2011 08:58:24 GMT

Content-Length: 88 Connection: Keep-Alive Set-Cookie:
_PMG_session=BAh7CkkiCmZsYXNoBjoGRUZJQzolQWN0aW9uRGlzcGF0Y2g6OkZsYXNoOjpGbGFzaEhhc2h7BjoLbm90aWNlSSIoSGFzIGluaWNpYWRvIHNlc2nDs24gY29ycmVjdGFtZW50ZS4GOwBUBjoKQHVzZWRvOghTZXQGOgpAaGFzaHsASSIQbW9iaWxlX3ZpZXcGOwBGRkkiEF9jc3JmX3Rva2VuBjsARkkiMWEyZW9oamFKT2tsWEZrbzZxc3lNenRhWTVEUk5XaHVUdm9iV3J3aFhFK1E9BjsARkkiGXdhcmRlbi51c2VyLnVzZXIua2V5BjsAVFsISSIJVXNlcgY7AEZbBmkGSSIiJDJhJDEwJEZQL20vZ29KU2FGUFZ0bmRzb0VZeS4GOwBUSSIPc2Vzc2lvbl9pZAY7AEYiJTA1NzI5YjFjOTMyZDdlMjk3YjEwYWQ5NWU3ZDJkZjYx–889ba65c483c3757b6aa47ffc2e187ac27a04dbe;
path=/; HttpOnly

Mobile login

Request

POST /users/sign_in HTTP/1.1

Host: localhost:3000

User-Agent: Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X;
en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341
Safari/528.16

Accept: text/html, /; q=0.01

Accept-Language: es-es,es;q=0.8,en-us;q=0.5,en;q=0.3

Accept-Encoding: gzip, deflate

Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7

Connection: keep-alive

Content-Type: application/x-www-form-urlencoded; charset=UTF-8

X-Requested-With: XMLHttpRequest

Referer: http://localhost:3000/users/sign_in.mobile

Content-Length: 195

Cookie: jstree_open=%231%2C%234%2C%235; jstree_load=;
_PMG_session=BAh7CkkiCmZsYXNoBjoGRUZJQzolQWN0aW9uRGlzcGF0Y2g6OkZsYXNoOjpGbGFzaEhhc2h7BjoKYWxlcnRJIkJOZWNlc2l0YXMgaW5pY2lhciBzZXNpw7NuIGNvbiB0dSBjdWVudGEgcGFyYSBwb2RlciBjb250aW51YXIuBjsAVAY6CkB1c2VkbzoIU2V0BjoKQGhhc2h7BjsHVEkiD3Nlc3Npb25faWQGOwBGIiUwMjY0ZGFkODY2MGY3YmE5ZWY4NmQzYmRmODUyNDUxOEkiEG1vYmlsZV92aWV3BjsARlRJIhN1c2VyX3JldHVybl90bwY7AEZJIgYvBjsARkkiEF9jc3JmX3Rva2VuBjsARkkiMTN5am1kaUhZcWpEZTAyclNNZ05ZNU5aZjA4bG5mamxCZHR6UmlVVHpkNFk9BjsARg%3D%3D–a6c9dbd6b27ac1b43193b4cba901b8862046dacf
Pragma: no-cache Cache-Control: no-cache

Response

HTTP/1.1 200 OK

Content-Type: text/html; charset=utf-8

Etag: “22b69d3da00b31c705b66d95aa8a32de”

Cache-Control: max-age=0, private, must-revalidate

X-UA-Compatible: IE=Edge

X-Runtime: 1.317610

Server: WEBrick/1.3.1 (Ruby/1.9.2/2011-02-18)

Date: Mon, 31 Oct 2011 09:06:47 GMT

Content-Length: 2915

Connection: Keep-Alive

Set-Cookie:
_PMG_session=BAh7C0kiCmZsYXNoBjoGRUZJQzolQWN0aW9uRGlzcGF0Y2g6OkZsYXNoOjpGbGFzaEhhc2h7BjoLbm90aWNlSSIoSGFzIGluaWNpYWRvIHNlc2nDs24gY29ycmVjdGFtZW50ZS4GOwBUBjoKQHVzZWRvOghTZXQGOgpAaGFzaHsASSIQbW9iaWxlX3ZpZXcGOwBGVEkiEF9jc3JmX3Rva2VuBjsARkkiMTN5am1kaUhZcWpEZTAyclNNZ05ZNU5aZjA4bG5mamxCZHR6UmlVVHpkNFk9BjsARkkiCWxpbmUGOwBGSSIGNQY7AFRJIhl3YXJkZW4udXNlci51c2VyLmtleQY7AFRbCEkiCVVzZXIGOwBGWwZpBkkiIiQyYSQxMCRGUC9tL2dvSlNhRlBWdG5kc29FWXkuBjsAVEkiD3Nlc3Npb25faWQGOwBGIiVhYWNkYzNlNjNhODU2ZWVjNmY1YmYzODEwNTk3NDA5Zg%3D%3D–31e22835ee0e428f80e0cf3f3ce5bd9fc8134d20;
path=/; HttpOnly

  • 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-26T12:52:27+00:00Added an answer on May 26, 2026 at 12:52 pm

    I’ve managed to solve the problem. Maybe I’ve should asked before to get the inspiration running 🙂

    Apparently, Devise was not able to redirect correctly when the request format was not HTML. Unfortunately I relied on the format to serve different templates for a mobile device using mobile_fu, and forcing the request format as devise wiki suggested order to get it running right with jquery mobile.

    The solution I’ve found is an ugly one:
    When the user makes the POST request to the devise controller -when is trying to authenticate- I force the html format instead of the mobile one. That way Devise is able to make the redirection correctly.

    Code for ApplicationController class:

    before_filter :set_mobile_format
    
    def set_request_format
      if is_mobile_device? # this method is provided by mobile_fu
        if (devise_controller? && action_name == 'create' && request.method == ('POST'))
          request.format = :html
        else
          request.format = :mobile
        end
      end
    end
    

    Hope this can help anyone who runs into the same problem.

    More elegant solutions are welcome!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT: This was formerly more explicitly titled: - Best solution to stop Kontiki's KHOST.EXE
edit #2: Question solved halfways. Look below As a follow-up question, does anyone know
Edit: I have solved this by myself. See my answer below I have set
EDIT: More detail here. Basically if you 1. open a tab1 to url1 (GET
Edit: From another question I provided an answer that has links to a lot
EDIT: This question is more about language engineering than C++ itself. I used C++
Edit : Solved, there was a trigger with a loop on the table (read
Edit: Maybe I made the question more complex than it should. My questions is
Edit: I'm looking for solution for this question now also with other programming languages.
Edit ok, great feedback here, got me pointed in the right direction. Use case

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.