Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 311
Anconia Avatar asked Jan 31 '26 00:01

Anconia


1 Answers

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

like image 71
CDub Avatar answered Feb 01 '26 16:02

CDub