Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Rails: Static Pages
- <hr>
- ## Rails Generate:
- * Rails provides a handy generator which ensures that all necessary files are generated for a given controller. To generate a controller and its views, type the following on your command line in your project's directory:
- ```
- $ rails generate controller welcome index about
- ```
- The output should look like this:
- ```
- create app/controllers/welcome_controller.rb
- route get 'welcome/about'
- route get 'welcome/index'
- invoke erb
- create app/views/welcome
- create app/views/welcome/index.html.erb
- create app/views/welcome/about.html.erb
- invoke helper
- create app/helpers/welcome_helper.rb
- invoke assets
- invoke js
- create app/assets/javascripts/welcome.js
- invoke scss
- create app/assets/stylesheets/welcome.scss
- ```
- * We passed three arguments to the rails generate command. The first argument represents the controller name, which is welcome. The next two arguments (index and about) represent views corresponding with the welcome controller. We could've named the controller and views anything, but the names should correspond with their primary function, as a best practice.
Add Comment
Please, Sign In to add comment