Nikolay Vetrov
Nikolay Vetrov

Reputation: 634

How can I route to index.html.erb?

I need route to index.html.erb? How can I do it? I tried root "index.html.erb#index" in routes.rb.

Upvotes: 0

Views: 1307

Answers (1)

Hardik Upadhyay
Hardik Upadhyay

Reputation: 2659

First of all, in rails we set routes for our controller's method not for our view file. Get method of controller redirect to view the page itself.

Write below code in your routes.rb:

get 'index', to: 'controller_name#index'

You can replace get 'index' with any name like get 'users'.

You can refer this for more reference.

Upvotes: 2

Related Questions