简体   繁体   中英

Heroku routing errors in Rails app

On my local machine, when I authenticate at http://subdomain.myapp.dev (using the Pow server), I am properly redirected to the index page.

When logging into the production domain http://subdomain.myapp.com (hosted on Heroku), I am also able to properly authenticate; however, Heroku is not redirecting to the index page. After submitting the necessary credentials, I receive the 'Signed in successfully' notification but remain on the sign in page.

rake routes and heroku run rake routes return identical routing schemes. I've also listed the contents of my routes.rb file below

Example::Application.routes.draw do  

  devise_scope :user do
    authenticated :user do
      root :to => 'admin/servers#index'
    end

    unauthenticated :user do
      root :to => 'devise/sessions#new'
    end
  end

  resources :server_imports
  resources :servers

  devise_for :users

  ActiveAdmin.routes(self)
end

Below are the logs after entering the credentials for signing in:

2013-10-12T01:59:32.110046+00:00 app[web.1]: Started POST "/users/sign_in" 
2013-10-12T01:59:32.529842+00:00 app[web.1]: Started GET "/"

And here is the first line from heroku run rake routes

root GET    /     admin/servers#index

As mentioned above, I still get re-routed to the sign in page after successful authentication. I am confused why this problem is only experienced on Heroku and not on my local machine

Why not do something like this:

def after_sign_in_path_for(resource)
    admin_servers_index_path
end

See: https://github.com/plataformatec/devise/wiki/How-To%3A-Redirect-to-a-specific-page-on-successful-sign-in-and-sign-out

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM