I would like to create two root
routes, one for authenticated users and one for non-authenticated users; for this I use devise , I tried the following code but it gives me an error.
Error
Invalid route name, already in use: 'root' You may have defined two routes with the same name using the
:as
option, or you may be overriding a route already defined by a resource with the same naming. For the latter, you can restrict the routes created withresources
as explained here: link
routes.rb
Rails.application.routes.draw do
devise_for :users
authenticated :user do
root 'main#home'
end
unauthenticated :user do
root 'main#unregistered'
end
end
main_controller
class MainController < ApplicationController
def home
end
def unregistered
end
end