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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:10:30+00:00 2026-05-26T16:10:30+00:00

I am using Devise with Ruby on Rails. I have a few pages that

  • 0

I am using Devise with Ruby on Rails. I have a few pages that I am using with a different mime-type – say /myapp/products.test … so I have registered a mime-type called ‘test’ and it resembles text/html … and I have content negotiation to either display the html.erb template or the test.erb template …

Now – when I have an authenticate_user! method in my controller – and I am using the ‘test’ mime-type – I don’t properly get redirected – I don’t get redirected at all – I just get a “You need to log in or sign up before continuing.” message.

What in Devise needs to overridden, so that it redirects when I use a mime-type other than html?

  • 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-26T16:10:31+00:00Added an answer on May 26, 2026 at 4:10 pm

    I found part of the answer on the following wiki page: https://github.com/plataformatec/devise/wiki/How-To:-Make-Devise-work-with-other-formats-like-mobile,-iphone-and-ipad-(Rails-specific)

    So – in summary (besides registering the mime type etc as explained in the question):

    In the config/initializers/devise.rb file, uncomment the config.navigational_formats line and replace with:

    config.navigational_formats = [:"*/*", "*/*", :html, :test]
    

    Add a file to the initializers, and add the following to it:

    ActionController::Responder.class_eval do
      alias :to_test :to_html
    end
    

    I also needed to override a devise method because my mime type actually responds to html too – but I do want to see whether it also responds to :test. So again in the initializers folder, add a file that contains the following:

    module Devise
      module Controllers
        # Helpers used in both FailureApp and Devise controllers.
        module SharedHelpers
    
          protected
    
          # Helper used by FailureApp and Devise controllers to retrieve proper formats.
          def request_format
            @request_format ||= if request.format.test?
              :test
            elsif request.format.respond_to?(:ref)
              request.format.ref
            elsif MIME_REFERENCES
              request.format
            elsif request.format # Rails < 3.0.4
              request.format.to_sym
            end
          end
    
        end
      end
    end
    

    It may be that it would have been cleaner – instead of overriding the above method – to override a method in Warden that does the redirect to the unauthorized url – but I couldn’t quite figure it out, and also uncertain whether Devise (upstream) isn’t the better place to override methods.

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

Sidebar

Related Questions

I have an app that is using devise for authentication. Rails 3 on ruby
I need to know how configure the gem devise,Im using ruby 1.9.2, rails 3.1.3,
Hi I am using devise for my auth system in rails. I have 2
I'm using Devise as authenticating solution in Rails and I have a cached fragment
I have a twitter like web application written in Ruby on Rails that allows
I'm working on a Ruby on Rails application that used the Devise authentication system.
I'm using Rails 3, on ruby 1.8.7. And using for auth. devise (1.1.3). But
I am using Devise in my Ruby on Rails 3 application. I am trying
I'm using Devise for user authentication and basic authentication. Let's say I have defined
I'm using devise 1.5.3 with rails 3.1.3, ruby 192, Im following this tutorial: http://ecuadoronrails.org/creando-un-sistema-de-autenticacion-de-usuarios-en-ruby-on-rails/#more-186

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.