Chapter 3 Flashcards
where are rails actions?
in the controller
switch to branch “static-pages”
git checkout -b static-pages
how can we generate a controller?
rails generate command to generate scaffolding
steps to make a controller to handle static pages
create StaticPages controller using generate. plan to make actions for home page, help page and about page.
$ rails generate controller StaticPages home help
$ rails generate conroller StaticPages home help
generates StaticPages controller with actions for home and help
scaffolding
generate major pieces of an application to create models, views, and controllers for a new resource
rails g
rails generate shortcut
rails c
rails console shortcut
bundle install
bundle shortcut
rake test
rake shortcut
git push -u origin static-pages
pushes topic branch up to github
destroy controller StaticPages:
rails destroy controller StaticPages home help
generate a model using scafffolding
rails generate model User name:string email:string
undo model generated User
rails destroy model User
bundle exec rake db:migrate
change the state of the database
undo db:migrate
bundle exec rake db:rollback (undo a single migration)
route file
responsible for implementing the router(defining the correspondence between URLs and web pages).
get ‘static_pages/home’
located in cofig: maps requests for the URL /static_pages/home to the home action in the Static Pages controller.
get ‘static_pages/home’ what is get
using get we arrange the route to respond to a GET request, HTTP
http
basic operations get, post, patch, and delete. operations between a client(chrome firefox) and a server(apache or nginx). emphasis on http verbs is typical of web frameworks influenced by the rest architecture.
get method
reading data on the web. just means ‘get a page’. everytime you visit google your browser submits a get request
post method
request sent by your browser when you submit a form. in rails, post are typically used for creating things(http also allows post to perform updates.
patch method
updating things on remote server
delete mthod
destroy things on remote server