w3d4 notes Flashcards
What does the following do?
a, b, c = *Array.new(3, 2)
Sets a, b, and c to 2, because a 3 element array of 2s is created with #new, and splat separates out the values.
T/F: Never override #initialize in Rails.
T
What happens when you discard an instance of a model?
The db is left untouched, unless you use #destroy
Why should you not use instance variables in Rails?
They do not persist; the values of them are unreliable.
What should you use instead of ::count? Why?
You should use #length, b/c ::count will fire the query.
What should you use in SQL to check for equivalency to NULL?
IS NULL
Does SQL have short-circuiting?
No
How should you structure associations to avoid data duplication?
Only connect models in a linear fashion.