Paul S.
Paul S.

Reputation: 4492

Get "home/index" in Rails project

After running rails generate controller home index in my Rails application, I see this line in routes.rb

get "home/index"

What does this line do? When I removed it, I didn't observe any difference it makes.

Upvotes: 1

Views: 901

Answers (1)

Kyle
Kyle

Reputation: 22258

see the Rails Routing page for more info but...

It adds, to the routing table, an entry to direct a GET request of the form

http://localhost:3000/home/index

To the HomeController#index action, which will render a response and display the results to the user.

It is a shorthand notation for

match 'home/index' => 'home#index', :via => :get

To see what other routes your application has available, run the following from a terminal while inside your projects directory

rake routes

Upvotes: 2

Related Questions