VOOZH about

URL: https://www.codecademy.com/article/standard-controller-actions

⇱ Standard Controller Actions | Codecademy


Skip to Content
Articles

Standard Controller Actions

Ruby on Rails defines seven standard controller actions can be used to do common things such as display and modify data.

👁 Seven actions

If you want to create routes for all seven actions in your app, you can add a resource route to your routes file. This resource route below maps URLs to the Messages controller’s seven actions (index, show, new, create, edit, update, and destroy):

resources :messages
Copy to clipboard
Copy to clipboard

If you only want to create routes for specific actions, you can use :only to fine tune the resource route. This line maps URLs only to the Message controller’s index and show actions.

resources :messages,only:[:index,:show]
Copy to clipboard
Copy to clipboard
  • Learn to program in Ruby, a flexible and beginner-friendly language used to create sites like Codecademy.
    • Beginner Friendly.
      9 hours9 hours
  • Dive deeper into the world of GitHub and learn about its more advanced features like Actions, Codespaces, and github.dev.
    • With CertificateWith Certificate
    • Intermediate.
      < 1 hour< 1 hour
Codecademy Team

'The Codecademy Team, composed of experienced educators and tech experts, is dedicated to making tech skills accessible to all. We empower learners worldwide with expert-reviewed content that develops and enhances the technical skills needed to advance and succeed in their careers.'

Meet the full team

Learn more on Codecademy