Create a new action for existing controller

Viewed 11425

I know this is probably a newbie question, but is it possible to create a new action (method in controller & associated view) from the command line on an existing controller?

For example, I already have a controller named 'Products'. Could I run:

rails g controller products [new_action]

and then rails would insert:

def [new_action]

end

Into my products controller and create a new file called '[new_action].html.erb' in the views/products/ directory? I have already googled this, but no satisfactory answer was returned. Also, I would just go ahead and try it, but I am pretty far into the development of my current app and really do not want to mess anything up.

3 Answers
Related