Tom Odell
Tom Odell

Reputation: 41

No route matches [GET] "/index" Ruby on Rails error

I am new to Rails and i have got this code in my routes.rb

Rails.application.routes.draw do
  get 'welcome/index' => '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'

But in localhost:3000/index it shows me this error

No route matches [GET] "/index"

What may be the problem?

Upvotes: 0

Views: 2445

Answers (1)

Chase
Chase

Reputation: 2826

get 'welcome/index' => 'welcome#index'

This code will generate a route for localhost:3000/welcome/index.

get 'index' => 'welcome#index' 

will generate the route you want. See the docs for more details http://guides.rubyonrails.org/routing.html

Upvotes: 2

Related Questions