w4d3 - rails views Flashcards
How do you validate uniqueness of a combination?
validates :attribute, uniqueness: { scope: :attribute2 }
What do views do?
Generate and populate the Response object
What context is a view evaluated in?
the controller
How do you render a view named show.html.erb?
render :show
How do you delete the current line in atom?
CMD + X
What’s the relationship between the new/create actions?
new - render a form
create - receive the form data and act on it
What’s the relationship between the edit/update actions?
edit - renders the form
update - receives form data and acts on it
What params would you send into a url helper?
wildcards
note that if you send in a model, its id will be populated automatically
What are the two ways of setting up a label?
For:
[label for=’id_of_thing’]body[/label]
Subling/wrap:
[label]body[input type=’text’/][/label]
What’s the difference between #update_attributes and #update?
They’re the same (alias for one another)
Where do you generally redirect to?
The model_url helper, where model is the name of the model
How can a form send an array back within the post params?
input name=’model[array_name][ ]’
Use this multiple times within the same form.
What’s the primary function of cookies?
To preserve state between HTTP requests
What are the 2 primary distinctions between hashing functions and cryptographic hashing functions?
- Speed. Cryptographic is slower.
2. Collisions. Cryptographic creates far fewer collisions.
How do you see the class inheritance path for an object?
objectname.class.ancestors