Question about ruby script/generate controller

Imagine I have a model called blog and I then run the following
command to create a controller for it.

ruby script/generate controller Blogs index

At some later point I want to create a ‘new’ page to submit blogs. Is
there a recommended way for doing this? Should I simply create the
file app/views/blogs/new.html.erb or should I instead run the command
below? Is there any difference?

ruby script/generate controller Blogs new


On Thu, Aug 13, 2009 at 10:02 AM, shusseina [email protected]

Just use your text editor of choice and create the template
file, new.html.erb.
Then you need to remember to add the action, ‘new’, to the

ruby script/generate controller Blogs new

Now, if you run the command again on the same controller, you should see
something like this:

 exists  app/controllers/
  exists  app/helpers/
  exists  app/views/posts
  exists  test/functional/
  exists  test/unit/helpers/

overwrite app/controllers/blogs_controller.rb? (enter “h” for help)

Then you can select ‘n’ if you have modified blogs_controller.rb or ‘Y’
have not modified this file. Then you’ll need to add the controller
to blogs_controller.rb but you wouldn’t have to create the new.html.erb

Good luck,