Guest User

Untitled

a guest
Feb 20th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. # Rails: Static Pages
  2.  
  3. <hr>
  4.  
  5. ## Rails Generate:
  6.  
  7. * 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:
  8. ```
  9. $ rails generate controller welcome index about
  10. ```
  11. The output should look like this:
  12. ```
  13. create app/controllers/welcome_controller.rb
  14. route get 'welcome/about'
  15. route get 'welcome/index'
  16. invoke erb
  17. create app/views/welcome
  18. create app/views/welcome/index.html.erb
  19. create app/views/welcome/about.html.erb
  20. invoke helper
  21. create app/helpers/welcome_helper.rb
  22. invoke assets
  23. invoke js
  24. create app/assets/javascripts/welcome.js
  25. invoke scss
  26. create app/assets/stylesheets/welcome.scss
  27. ```
  28. * 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