1/30/17 Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What does the as: :profile do in this route?

get ‘:username’, to ‘profile#show’, as: :profile

A

The as: :profile line let’s us use handy Rails routing helpers in our code. This will let us user the profile_path helper (just as we’ve used post_path or posts_path previously)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

From the controller’s point of view, there are three ways to create an HTTP response, what are they?

A
  1. Call render to create a full response to send back to the browser
  2. Call redirect_to to send an HTTP redirect status code to the browser
  3. Call head to create a response consisting solely of HTTP headers to send back to the browseriv
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Give and example of Convention Over Configuration in rails when it comes to rendering a template without specifying a view in the controller.

A

The rule is that if you do not explicitly render something at the end of a controller action, Rails will automatically look for the action_name.html.erb template in the controller’s view path and render it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do you render a template from a different controller?

A

render “controller_name/action_name_template”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly