gaku様の備忘録

プログラミングとか、夢と現実と理想とか。。。

deviseのrootルーティング設定方法

rootを設定する場合、以下のようにする

まずはルーティングの確認

$ bundle exec rake routes

config/routes.rbで以下のような形で追加を行う。(各自編集してください。)

  #deviseのルート設定の場合は以下のように指定
  devise_for :users
  devise_scope :user do
    authenticated :user do
      root :to => 'timelines#index', as: :authenticated_root
    end
    unauthenticated :user do
      root :to => 'devise/sessions#new', as: :unauthenticated_root
    end
  end

これで認証してる時としていない時で別々のルートを設定することができる。