method

root

Importance_2
Ruby on Rails latest stable (v7.1.3.2) - 1 note - Class: ActionDispatch::Routing::Mapper::Base

Method deprecated or moved

This method is deprecated or moved on the latest stable version. The last existing version (v4.2.9) is shown here.

These similar methods exist in v7.1.3.2:

root(options = {}) public

You can specify what Rails should route “/” to with the root method:

root to: 'pages#main'

For options, see match, as root uses it internally.

You can also pass a string which will expand

root 'pages#main'

You should put the root route at the top of config/routes.rb, because this means it will be matched first. As this is the most popular route of most Rails applications, this is beneficial.

Show source
Register or log in to add new notes.
March 28, 2012 - (>= v3.0.0)
0 thanks

:as option

Code

root :to => 'projects#index', :as => 'foobar'

will generate a helper

foobar_path