Ruby on Rails 8 cheatsheet
Ruby on Rails 8: Generators
7 common Ruby on Rails 8 tasks.
Generate a model
Create a model, its migration and a test.
bin/rails generate model Article title:string body:text
Generate a controller
Create a controller with index and show actions and their views.
bin/rails generate controller Articles index show
Generate a full CRUD scaffold
Create model, controller, views, routes and tests in one go.
bin/rails generate scaffold Post title:string body:text
Generate a migration
Create a migration that adds a column. Rails reads the intent from the name.
bin/rails generate migration AddSlugToArticles slug:string
Generate authentication
Add the built-in authentication system introduced in Rails 8: sessions, users and password reset.
bin/rails generate authentication
Undo a generator
Remove the files a generator created.
bin/rails destroy model Article
Caution: Deletes the generated files. It does not roll back a migration you have already run.