How to generate a controller?


How do you generate a controller on ruby on rails?


Hi Colejamesh,

The basic syntax to create something in Rails is:

$ rails [new/generate] [type] name


$ rails new Name
  # creates a new RoR project named Name
$ rails generate controller Things
  # creates a new controller called Things
$ rails generate model Thing
  # creates a new model called Thing

You need to run the second command, rails new controller [controller name] to generate a controller :)