DEV Community

Cover image for Rails Standard Controller Actions
Evelyn Hernandez
Evelyn Hernandez

Posted on

Rails Standard Controller Actions

Controller actions: Are the methods created inside the controller file, which are used for displaying and modifying data.

Image description

  • HTTP Verb exists in your config/routes.rb file.
  • Path refers to the URL a user inputs in their browser.
  • Controller#action refers to the actions in the app/controllers/messages_controller.rb.

If you want to create routes for all 7 actions in your app, you can add a resource route to your routes.rb file. The resource route maps URLs to the Messages controller's 7 actions which are (index, show, new, create, edit, update and destroy)
resources :messages

If you only want to create routes for specific actions, use :only. The code line below maps URLs only to the Messages controller's index and show actions.
resources :messages, only: [:index, :show]

Here is a link on more information about Rails Routing

Top comments (0)