Reputation: 519
Disclaimer : I am a total novice to programming itself , I have done some C++ stuff only . I had an idea and wanted to code the preliminary part of the website myself. Hence , I looked around and decided to jump on to the Ruby on Rails bandwagon. But I am not quite getting the grip of the generate command and how is it being very different from scaffold. Again , please pardon me , I am starting out and thought if anyone over here can guide me to good tutorials or easy way of making it understand . Any answers, small or big are appreciated !
I am following The Intro to RoR ( Berkeley events youtube ) set but it seems outdated , so I have been trying to follow random youtube videos .
Upvotes: 0
Views: 94
Reputation: 3937
The official Rails Guides are a great place to learn all things Rails. In this case, there is a A Guide to the Rails Command Line which spells out the difference. Essentially, a Rails scaffold "is a full set of model, database migration for that model, controller to manipulate it, views to view and manipulate the data, and a test suite for each of the above." generate
, on the other hand, is used to create models and controllers separately.
The obvious thing I should say here is: do both and look at the differences. If you're new and you find Rails and/or the command line daunting, play with it and figure it out. Create some new project (rails new foo
) that you can throw away later. Change into the foo directory, then type rails generate scaffold Bar
, take note of the files created and what's in those files, then go back to the command line and type rails destroy scaffold Post
. Then do the same with rails generate controller
and rails generate model
. The best way to understand is by experimenting yourself.
Upvotes: 3