I have two controllers: Tasksadmins and Workers.
I defined two roots, but someone told me that there is a problem with it.
can someone tell me what the problem is?
TODOLIST::Application.routes.draw do
devise_for :users
resources :tasksadmins
root to: "tasksadmins#index"
resources :workers
root to: "workes#index"
end
rootdoesn’t mean theindexaction of a controller. Instead, it means essentially the home page: what action gets called when I go tohttp://www.example.com/?Therefore, it only makes sense to define one
root: right now, you’re pointinghttp://www.example.com/to bothtasksadmins#indexandworkers#index, which doesn’t make much sense. Rails will just pick one of them, but that’s probably not the behavior you’re looking for.I suspect you’re trying to refine your
resourcesroutes, but there’s no need:resources :workersalready defines the routehttp://www.example.com/workerspointing toworkers#index, so that line should be all you need for the workers.If, however, you want
http://www.example.com/to point to the same workers listing ashttp://www.example.com/workers, thenroot 'workers#index'is exactly right.