<— TutorialStepTwo | Tutorial | TutorialStepFour (Creating a model) —>
Create a new controller (UnderstandingControllers) using the ‘script/generate controller’ generator
(run with no arguments for documentation).
We’ll create a controller called Friends:
./script/generate controller Friends list view new edit
Note: in Windows run as:
ruby script/generate controller Friends list view new edit
Your output will be similar to this:
$ ruby script/generate controller Friends list view new edit
exists app/controllers/
exists app/helpers/
create app/views/friends
exists test/functional/
create app/controllers/friends_controller.rb
create test/functional/friends_controller_test.rb
create app/helpers/friends_helper.rb
create app/views/friends/list.rhtml
create app/views/friends/view.rhtml
create app/views/friends/new.rhtml
create app/views/friends/edit.rhtml
A controller called
friends_controller.rbis created in the
app/controllersdirectory. The controller will have 4 routines
For each of these four routines in the new controller class, a view template .rhtml file has also been generated.
<— TutorialStepTwo | Tutorial | TutorialStepFour (Creating a model) —>