Details Flashcards
True or false: rails g controller NAME - NAME should be plural?
True.
True or false: rails g model NAME - NAME should be plural?
False.
True or false: migration are created when a model is generated?
True.
In Ruby, how is a multi-line comment created?
=begin…=end
What does an exclamation point (!) mean in .capitalize! and other Ruby string methods?
If an ! is present, the existing string is destructively altered rather than a new string being spawned.
Ruby loops and iterators include:
Unless, While, Until, For
What’s the syntax difference between an inclusive and exclusive FOR statement?
Exclusive: 1…20 (three dots), inclusive 1..20 (two dots)
What closes a “loop do” statement?
Break if condition…end.
Syntax of a Ruby LOOP statement?
counter = 1; loop do…break if counter…end
Ruby on Rails common migration options (6):
default: , limit: 29, null: false, first: true, after: email, unique: true
Generate a migration to add columns to a table.
rails g migration AddTo col1:string col2:integer col3:boolean
Generate a migration to remove columns from a table.
rails g migration RemoveFrom col2:integer
List 5 additional migration commands.
rename_column :zombies, :bio, :description
rename_table :zombies, :ghouls
drop_table :zombies
change_column :zombies, age: integer, limit: 4
change_column_default :zombies, :is_admin, default: true
What is this syntax called? { :name => “Jon” }
Rocket syntax.
What is this syntax called { name: “Jon” }
Hash syntax. It’s the preferred data definition syntax in Ruby 1.9.
Ruby on Rails common migration options (6):
default: , limit: 29, null: false, first: true, after: email, unique: true
Generate a migration to add columns to a table.
rails g migration AddTo col1:string col2:integer col3:boolean
Generate a migration to remove columns from a table.
rails g migration RemoveFrom col2:integer
List 5 additional migration commands.
rename_column :zombies, :bio, :description
rename_table :zombies, :ghouls
drop_table :zombies
change_column :zombies, age: integer, limit: 4
change_column_default :zombies, :is_admin, default: true
What is this syntax called? { :name => “Jon” }
Rocket syntax.
What is this syntax called { name: “Jon” }
Hash syntax. It’s the preferred data definition syntax in Ruby 1.9.
What does RAKE NOTES do?
Rake notes will search through your code for comments beginning with FIXME, OPTIMIZE or TODO. The search is done in files with extension .builder, .rb, .erb, .haml and .slim for both default and custom annotations.
What does the prefix BUNDLE EXEC do?
bundle exec is a bundle command to execute a script in the context of the current bundle (the one from your directory’s Gemfile).