How To: Define a different root route for logged out users - heartcombo/devise GitHub Wiki

This works in Rails 5.1+

Rails.application.routes.draw do
  devise_for :users

  authenticated :user do
    root 'secret#index', as: :authenticated_root
  end

  root "home#index"
end

For Rails 6, you must use unauthenticated and it must come before the authenticated block.

Rails.application.routes.draw do
  devise_for :users

  unauthenticated do
    root "home#index"
  end

  authenticated :user do
    root 'secret#index', as: :authenticated_root
  end
end