Q:

Trouble with Multiple Rails app routing on Facebook omniauth login

I'm currently maitaining a Rails project that needs to switch its Passenger Rack Middleware to Unicorn. I've bumped into an issue that Unicorn does not seem support subdomain that much, so I have a workaround like the below.
require_relative '../lib/route_scoper'

MyProject::Application.routes.draw do
  scope RouteScoper.root do
    get "pages/welcome"

    mount RailsAdmin::Engine => '/admin', as: 'rails_admin'

    devise_for :users, controllers: { omniauth_callbacks: "omniauth_callbacks" }

    root to: "pages#welcome"

    resources :categories, only: [:index, :show]
    resources :counties, only: [:index], defaults: { format: :json }
    resources :products, only: [:show] do
      resources :votes, only: [:create]
    end

    resources :tickets, only: [:new, :create]
  end
end

I've made a workaround according to the article here
Multiple Rails 4 app using nginx + unicorn
Everything works fine except our Facebook Login seems to have a routing problem.
Started GET "/my_project"
Processing by Devise::CasSessionsController#service as HTML
Redirected to http://events.staging.mainsite/users/auth/facebook
Filter chain halted as :sync_fb_user rendered or redirected
Completed 302 Found in 49.8ms (ActiveRecord: 0.0ms)

The Rails project is under a domain name like
http://events.staging.mainsite/my_project
It always redirect me to http://events.staging.mainsite/users/auth/facebook page and show error message 404 not found.
It's used to route at the URL like the below from the old version
Redirected to /my_project/users/auth/facebook

Not sure if I can overwrite the omniauth path to fix this or simply modify the route.rb to point to the right login path, thanks for the help.

A:

Well I just figured this out, I have to add a path for my devise
then move it outside the RouteScoper.
devise_for :users, controllers: { omniauth_callbacks: "omniauth_callbacks" }, path: "#{RouteScoper.root}/users"

