rails g controller with actions

  1. Open your terminal or command prompt.

  2. Navigate to your Rails application directory.

  3. Run the command "rails g controller ControllerName action1 action2" replacing "ControllerName" with the name of the controller you want to create, and "action1" and "action2" with the names of the actions you want to include in the controller.

  4. This command will generate a new controller file in the "app/controllers" directory of your Rails application, as well as corresponding views in the "app/views/controller_name" directory.

  5. The "action1" and "action2" specified in the command will create methods in the controller file for handling the corresponding actions, along with view files for each action in the "app/views/controller_name" directory.

  6. You can then add the necessary logic to the controller methods to handle the actions, and customize the corresponding view files in the "app/views/controller_name" directory to display the desired content.