Dharmil
Dharmil

Reputation: 63

Ruby on Rails, Routing

Just wanted to know, what does this line mean in the routes.rb file:

AppName::Application.routes.draw do

Please explain. I am new to Rails.

Upvotes: 4

Views: 79

Answers (2)

Tabish Maniar
Tabish Maniar

Reputation: 15

It is the main routes file which defines the root and other paths for the link. It is used as suppose you want to change your index page from default ruby on rails to your index page you make changes to file and add

 root to: "controllername#index"

This file is also used to add the model to the application

 resources: "model_name"

Apart from this you can also define links in your rails application

get 'courses/index'

So going from courses controller to view of the index.

Upvotes: 0

rlarcombe
rlarcombe

Reputation: 2996

Have a read through this page. Basically, within the block passed to Application.routes.draw (which is just a call to a method defined in ActionDispatch::Routing module within the Rails core framework), you define all the URLs/Paths that you want your Rails application to respond to.

You can see all these route definitions, by running:

rake routes

in your terminal.

Upvotes: 1

Related Questions