Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make Sign up page be root page in Devise?

I'm running on Rails 4.0.0 with Devise 3.1.0. My routes are setup like this:

devise_for :users do
  root "devise/registrations#new"
end

resources :books

What I'm trying to do is make the Devise Sign Up Page be the Welcome Page for users if they haven't signed in but if their signed in they'll go to the Book Index. Right now it just gives me the standard Ruby on Rails:Welcome Aboard page as if Devise doesn't exist. How would I do this?


Answer

https://github.com/plataformatec/devise/issues/2393

devise_for :users
devise_scope :user do
  authenticated :user do
    root :to => 'books#index', as: :authenticated_root
  end
  unauthenticated :user do
    root :to => 'devise/registrations#new', as: :unauthenticated_root
  end
end
like image 680
user2784630 Avatar asked Sep 19 '13 19:09

user2784630


1 Answers

devise_for :users
devise_scope :user do
  authenticated :user do
    root to: 'books#index'
  end
  unauthenticated :user do
    root to: 'devise/registrations#new', as: :unauthenticated_root
  end
end
like image 88
Fabian Winkler Avatar answered Nov 09 '22 20:11

Fabian Winkler