How to start Lesson 3 Controller (Rails)


Now that we have a model, let's move on to the second and third parts of the request/response cycle and create a controller and a route.
Generate a controller named Messages.
How should i generate a controller?


Hi 林子安,

The basic syntax to create something in Rails is:

$ rails [new/generate] [type] name


$ rails new MessageApp 
  # creates a new RoR project named MessageApp
$ rails generate controller Messages 
  # creates a new controller called Messages
$ rails generate model Message
  # creates a new model called Message

You need to run the second command, rails new controller Messages.