Chapter 3 Flashcards
What does running ‘bundle update’ accomplish?
Updates the gemset to match those specified by the Gemfile
What does the ‘git mv’ command accomplish?
Moves the contents of one file to another file. Since we are moving, not copying, the original file is destroyed.
How can we see Heroku’s logs to help diagnose a problem?
$ heroku logs
In making a dynamic page, what are actions/views and controllers for?
Actions/views contain only static HTML, and controllers contain sets of actions (functions) related by a common purpose.
What is the syntax for generating a controller?
$ rails genreate controller controllerName optionalAction1 optionAction2
How can we push a branch besides master to BitBucket, thereby changing the branch we are pushing?
Include the -u flag and origin parameter, and add one final argument with the name of the branch to push:
$ git push -u origin static-pages
T/F: When giving a generator a controller name, it automatically converts CamelCase to snake_case
T
Explain the following command:
$ rails destroy controller StaticPages home help
After generating this controller, we can mimic the command with the ‘destroy’ directive instead to undo changes. Note that additional command line arguments must also be added in order to be included in the rollback
How can we undo a database migration we performed with the db:migrate command?
$ bundle exec rake db:rollback
OR, to go back to the beginning:
$ bundle exec rake db:migrate VERSION=0
Explain the rule in the routes.rb file:
get ‘static_pages/home’
When we passed the ‘home’ parameter to the generator for the StaticPages controller, Rails added a route to access these pages when given as part of a URL
Furthermore, by using ‘get’ we arrange for the route to respond to a GET request
What are four of the most common HTTP operations?
GET, POST, PATCH, DELETE
Explain GET, POST, PATCH, and DELETE in the context of Rails
GET: Used to read data; sends a request from client to server to get a page
POST: Used for creating things; a request sent by client to submit a form
PATCH: Updates things on a server
DELETE: Deletes things on a server
What is Rake?
Short for Ruby make; a make-like language written in Ruby
T/F: When using scaffolding, the resulting controller uses REST architecture, whereas when only a controller is generated, not all of the REST architecture is used
T
When generating a controller, what do the additional parameters do in the controller file?
They are added as functions within the controller’s class