Standard Controller Actions
Ruby on Rails defines seven standard controller actions can be used to do common things such as display and modify data.
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
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]
'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 teamRelated articles
- Article
Building a To-Do List with Ruby on Rails
Learn how to build a To-Do List with Ruby on Rails - Article
How to Use GitHub Actions: A Step-by-Step Tutorial
Explore how GitHub Actions can automate your workflows, enhance your CI/CD practices, and simplify your development processes! - Article
How to Implement MVC Architecture in a Full-Stack App
Learn how to implement MVC architecture in a full-stack expense tracker app using JavaScript, Node.js, Express, React, and PostgreSQL.
Learn more on Codecademy
- Free course
Learn Ruby
Learn to program in Ruby, a flexible and beginner-friendly language used to create sites like Codecademy.Beginner Friendly9 hours - Course
Learn GitHub: Actions and Codespaces
Dive deeper into the world of GitHub and learn about its more advanced features like Actions, Codespaces, and github.dev.With CertificateIntermediate< 1 hour - Free course
Velo by Wix: Using Async Actions for the Backend
Integrate JavaScript asynchronous actions with Velo to create a backend.Beginner Friendly4 hours