Skip to main content

restful_resources

📦 Use RESTful resources for CRUD routes​

Defining a RESTful resource generates all seven standard CRUD routes (index, show, new, create, edit, update, destroy) with a single line of code. This keeps your config/routes.rb concise and follows Rails conventions, making your routes predictable and easy to work with.

# config/routes.rb
Rails.application.routes.draw do
resources :articles
end

After this, you can use helper methods like articles_path, new_article_path, and edit_article_path(@article) throughout your controllers and views.