Skip to content

Instantly share code, notes, and snippets.

View kkchu791's full-sized avatar

Kirk Chu kkchu791

  • Los Angeles, CA
View GitHub Profile

##Quiz: Lesson 3 Solutions

####1. What's the difference between rendering and redirecting? What's the impact with regards to instance variables, view templates?

Rendering displays a view template that accesses the instance variables available in that action. Therefore, instance variables must be declared in that action before the render will work. Redirecting will send a new request to the browser based on the route path that was provided. In this case, the instance variables in that action are not related to the redirected view.

####2. If I need to display a message on the view template, and I'm redirecting, what's the easiest way to accomplish this?

You can use flash, which saves the message with a session. The message will be displayed on your next action and will be removed after that. flash[:message] = 'Your account was created.' redirect_to :back