Chapter 7 Flashcards
rails command for running test suite
$ bundle exec rake test
rails command for starting a console session where session commands are rolled back at end of session.
$ rails console –sandbox
$ rails generate model User name:string email:string
What does name:string do in this command?
in the migration file that this command generates, the migration will have functions which add a Name row to the db table. Entries in this row will be string objects.
How would you run the rails server in a different environment?
$ rails server –environment production
$ rails s –environment test
What are the three Rails environments?
development, test, and production
If you view your app running in production, it won’t work without a production database, which we can create by running rake db:migrate in production:
what is the rails command for that?
$ bundle exec rake db:migrate RAILS_ENV=production
Command for displaying a gems location.
$ bundle show [gem]
HTTP’s four fundamental operations
POST, GET, PATCH, DELETE
method for changing a resource’s attributes
update_attributes
command for resetting the database, aka wiping out all entries
$ bundle exec rake db:migrate:reset
ORM
stands for
Object Relational Mapper
Initializing an object with a hash as an argument is called:
Mass assignment
user.errors.count
what will the #count method do?
return the number of errors
Jargon word for temporary message that displays on web page
flash
rails method for constructing a form
form_for
command for showing list of all routes
$ rake routes
command for running a single test
$ rake test TEST=[path/file]
variant of flash method for displaying flash message on rendered pages
flash.now
method for storing a cookie in client until client browser closes
session
||=
what is this operator called?
the “or equals” operator
var ||= ‘Hi’
var is set to ‘Hi’ only if var is nil
$ bundle exec rake test TEST=test/integration/users_login_test.rb \
> TESTOPTS=”–name test_login_with_valid_information”
________
What does this command do?
runs a specific single test “test_login_with_valid_information” within a specific file “users_login_test.rb”
session.delete(:user_id)
_______
what does this accomplish?
This method is used to log a user out, to remove the cookie, ending the “session.”
what is a migration?
a migration modifies a database to add or remove tables, columns, or entries
$ rails generate migration add_remember_digest_to_users remember_digest:string
_______
what files will this command generate, and what will the files do?
creates a migration ruby file which adds the column remember_digest to a users table.