1/30/17 Flashcards
What does the as: :profile do in this route?
get ‘:username’, to ‘profile#show’, as: :profile
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)
From the controller’s point of view, there are three ways to create an HTTP response, what are they?
- Call render to create a full response to send back to the browser
- Call redirect_to to send an HTTP redirect status code to the browser
- Call head to create a response consisting solely of HTTP headers to send back to the browseriv
Give and example of Convention Over Configuration in rails when it comes to rendering a template without specifying a view in the controller.
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 do you render a template from a different controller?
render “controller_name/action_name_template”