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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T02:01:32+00:00 2026-06-17T02:01:32+00:00

I have an existing Rails 3 site. This site uses Devise to log in.

  • 0

I have an existing Rails 3 site. This site uses Devise to log in.

Now I need to add a subsite with a separate login. Let’s say that it is at mysite.com/special. Everybody that go to /special need to sign in with a different set of credentials than the main site. These credentials are not valid for the main site but they must, in parallel, be able to log into the main site and stay logged in both.

To complicate the picture a bit, ‘special’ users are able to impersonate a subset of regular users. If they do impersonate, sign out of the impersonation and so forth, they must remain logged into the special site until they explicitly sign out there.

My initial idea was to use a separate session cookie for this entire subsite but I don’t know how to do that. I tried setting something like this up but it is almost guesswork at this point.

scope '/special' do 
    devise_for :special_users, :controllers => { :sessions => "special/sessions" }, :skip => "registrations", :module => "special_users"
    unauthenticated do
      as :special_user do
        root :to => 'special/sessions#new'
      end
    end
end  

Unfortunately, I’m a bit new to Rails and this seems to be rather complicated. Is it even possible with Devise and if so, do anyone have any pointers as to how to go about it?

  • 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-06-17T02:01:33+00:00Added an answer on June 17, 2026 at 2:01 am

    As it turns out, this is what scopes are for. Everything makes much more sense when you know what they call it 😉 Anyway, Qumaras’ comment above was actually on the right track), and the tutorials and wikis are generally good sources of information. One possible approach:

      devise_for :spuser, :controllers => { :sessions => "sp/spusers/sessions"}
      as :spuser do # as = equiv. to devise_scope
        # add spuser specific items here, such as:
        unauthenticated :spuser do
          root :to => 'sp/spusers/sessions#new'
        end
      end
    

    Then if you want to sign in another tab as a regular user, you could do this in a controller.

    def impersonate
      @user = User.first
      sign_in(:user, @user)
      redirect_to '/main'
    end
    

    And wire the impersonate action up in routes.rb

    resources :regularcustomers do
      member do
        get :impersonate
      end
    end
    

    and then you can call it in a view:

    <%= link_to @customer.name, impersonate_regularcustomers_path(@customer), :target => 'impersonationtab' %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to rails, and have taken some existing site for new enhancements. I
I have an existing Rails site which is rendering very poorly on iPhone and
I have an existing Rails 2.3.x application that uses the follow block of code
I have an existing Rails app that uses tire (0.4.0) to interface with an
I have an existing rails backend website which makes json calls to server. Now,I
I have an existing Rails 3.1 application with a model Products with price, description,
I have an existing project written in Ruby on Rails. It is sort of
I have existing code that uses CMNewProfileSearch to find then iterate over the color
I have existing java code and need to create Design Document based on that.
I have an existing Ruby on Rails project. How do I find out which

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.