-2

I created model for user in ruby on rails using scaffold. Then I got to know that when I saw controller's folder of the project I would find usercontroller.rb file created ? Does this means that whenever model is created controllers are created with it ?

Imran Ali
  • 2,223
  • 2
  • 28
  • 41
  • No controller doesn't get created whenever model is created. It happens only for scaffolding. if you don't use scaffold generator you need to create them separately. – pk-n Aug 26 '16 at 18:14
  • when you run a scaffold command it generates relevant model, controller and view files for you. If you are not using the scaffold you can generate them separately one after the other – Imran Ali Aug 26 '16 at 18:14

2 Answers2

1

It isn't the model creation that does it, it's the scaffolding.

http://guides.rubyonrails.org/v3.2.9/getting_started.html

Section 6 of that document describes what is generated during scaffolding. The scaffolding process creates a number of files, controller being one of them.

Architect Nate
  • 674
  • 1
  • 6
  • 21
0

rails generate scaffold will generate a model, controller database migration, and views.

Here is a list of the generators that Rails provides:

  • assets
  • controller
  • generator
  • helper
  • integration_test
  • jbuilder
  • mailer
  • migration
  • model
  • resource
  • scaffold
  • scaffold_controller
  • task

The Ruby on Rails guides can provide you with additional information on the command line tools.

Alex Kitchens
  • 102
  • 1
  • 10