method

root

rails latest stable - Class: ActionDispatch::Routing::Mapper::Mapping::Resources

Method not available on this version

This method is only available on newer versions. The first available version (v8.1.1) is shown here.

root(path, 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.