[RUBY] Specify home view in rails app [root]

About root

You may want to specify the main screen in the rails app. In such a case, you can easily specify it by specifying root in routes.rb.

config/routes.rb


root to: "Controller name#Action name"

Now you can specify the main screen.

Let's write an example. If you want to specify the view of the index action of posts_controller on the main screen,

config/routes.rb


root to: "posts#index"

It is described as.

In this case, even if you do not write the index action in posts_controller, you can display it as a view as long as you have app / views / posts / index.html.erb.

Thank you for watching until the end.

Recommended Posts

Specify home view in rails app [root]
View monthly calendar in Rails
Create a new app in Rails
How to change app name in rails
Group_by in Rails
[Japanese localization] i18n rails Easy Japanese localization view display only
Implement iteration in View by rendering collection [Rails]
Use pagy for pagination in your Rails app.
[Rails] View sharing
Some subtly different repetitive writing styles in Rails View
[Rails] How to load JavaScript in a specific view
[Rails] How to display an image in the view
Do not write 〇〇 logic in Rails View (* added later)
Rock-paper-scissors app in Java
Adding columns in Rails
Disable turbolinks in Rails
CSRF measures in Rails
Heroku app moving (rails)
^, $ in Rails regular expression
Use images in Rails
Understand migration in rails
Split routes.rb in Rails6
Implement markdown in Rails
Launch the Rails app locally in production mode (API Server)
How to specify db when creating an app with rails
How to deploy jQuery in your Rails app using Webpacker
Apply CSS to a specific View in Ruby on Rails
[Rails] How to display information stored in the database in view