I am following a tutorial and got to this point: http://rubysource.com/building-your-first-rails-application-views-and-controllers/
rails generate controller urls new
The reason we only passed in the new action (instead of new, create,
and show) is because Rails automatically generates a dummy view for
each action included in the generator call. In this case, we only want
a dummy view for the new action, so we exclude the others.
So why we only need to create the controller for new? Can someone plase explain it in a little more details?
The command is used to create the
UrlsControllerwith only one method:new.This command will also automatically create a view file for you in:
Had you supplied more arguments like:
You would have gotten:
Since the tutorial only needs the
newview it was unnecessary to create the additional views, hence those additional arguments were not added to thegeneratecommand.Later in the tutorial you manually add the
createandshowmethods, but you never add views for those methods (since those methods will not be needing specific views files in this application).So: what you did was create the controller
UrlsControllerwith one methodnew, and the corresponding view for that method. The rest of the methods you will code in manually later in the tutorial so there was no need to auto-generate anything else (createorshow).