Controller Generator in Ruby

From the Ruby on Rails cheat sheet · Generators · verified Jul 2026

Controller Generator

Generate controllers with actions and views

bash
# Controller with actions
rails generate controller Users index show new create

# API controller
rails generate controller api/v1/Posts index show --skip-template-engine

# Empty controller
rails generate controller Admin
✅ Creates controller, views, helper, and routes
💡 --skip-template-engine for API-only controllers
🔍 Namespaced controllers use slashes: api/v1/Users
⚡ Actions listed after controller name become methods
generatorcontrollercrud

Continue with Ruby on Rails

Save the full cheat sheet or work through every related task.

More Ruby tasks

Back to the full Ruby on Rails cheat sheet