Ruby on Rails - rails generate controller in ruby on rails- ruby on rails tutorial - rails guides - rails tutorial - ruby rails
Rails Generate Controller
we can create a new controller with rails g controller command.
The controller generator is expecting parameters in the form of generate controller ControllerName action1 action2. The following creates a Greetings controller with an action of hello.
This generates the following
File | Example |
---|---|
Controller File | greetings_controller.rb |
View File | hello.html.erb |
Functional Test File | greetings_controller_test.rb |
View Helper | greetings_helper.rb |
JavaScript File | greetings.coffee |
It will also add routes for each action in routes.rb