Generate controller and actions in Rails
Rails controller generation is done with the help of Rake command line tool. Actions are added along with the controller. Action can be added directly into controller .rb file after initial controller generation. Here is a command line tool that does just that.
First example generates empty controller
> rails generate controller Product
Second example generate controller with two three actions: index, show, edit
>rails generate controller Products index
Both commands will add the following files to our Rails application
Note: it is important to name your controllers as plural in order for internal plumbing to work properly.