DEV Community

Cover image for Rails Standard Controller Actions
Evelyn Hernandez
Evelyn Hernandez

Posted on

2

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

AWS Q Developer image

Your AI Code Assistant

Automate your code reviews. Catch bugs before your coworkers. Fix security issues in your code. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more