How to generate a controller?


#1

How do you generate a controller on ruby on rails?


#2

Hi Colejamesh,

The basic syntax to create something in Rails is:

$ rails [new/generate] [type] name

So,

$ 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 :)