Getting Started: 5 Getting Up and Running

First foray into Rails, and everything’s smooth until I hit step 5 in the Getting Started docs.

After adding the article resource to config/routes.rb:

Adding a new resource, as per initial guide,

“Getting Up and Running”:

Rails.application.routes.draw do

resources :articles

root ‘welcome#index’



I receive the following error at http://localhost:3000/articles/new:


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 with resources as explained here:

with an indication that the issue is at “root ‘welcome#index’”

What am I missing here?

Enter code here…


Could you please show us your complete config/routes.rb?

Thx, looks like I figured it out. I had inserted the article resource within the body of the ‘welcome/index’ resource.

My current config/routes.rb file now looks lie this, and all is good:

Rails.application.routes.draw do

get ‘welcome/index’

The priority is based upon order of creation: first created -> highest priority.

See how all your routes lay out with “rake routes”.

You can have the root of your site routed with “root”

root ‘welcome#index’

Example of regular route:

get ‘products/:id’ => ‘catalog#view’

Example of named route that can be invoked with purchase_url(id:

get ‘products/:id/purchase’ => ‘catalog#purchase’, as: :purchase

Example resource route (maps HTTP verbs to controller actions automatically):

resources :products

Example resource route with options:

resources :products do

member do

get ‘short’

post ‘toggle’


You’re defining two Rails.application.routes.draw blocks there. You should only be defining one.