[Ruby] Ruby on Rails controller creation/deletion command

less than 1 minute read

Create controller

The command to create the controller is rails g controller controller name (plural, lowercase)

Example: rails g controller posts

If you add the action name after the controller name Routes, actions and views are created at the same time. rails g controller controller name action 1 action 2 …

Example: rails g controller posts index new

Delete controller

The command to delete the controller is rails destroy controller controller name

Example: rails destroy controller posts

** * It is not possible to omit destroy and write d **