root

root(options = {})
Instance Public methods

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

1
root to: 'pages#main'

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

You can also pass a string which will expand

1
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.

doc_ruby_on_rails
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.