Per GoRails, how variables in an action of a controller are passed to View can be thought as the following:
Description of the Steps (*not how Rails actually runs)
When a HTTP request comes into Rails and enters its Route...
On the inside, Rails creates a new instance of the controller and calls a certain method (or "action", in terms of MVC model), "show"
Now the instance has the instance variables in the method "show"
At the end of the action method it calls render() to bind variables in the ERB template (see default rendering in controllers) with instance variables that we just created
Variables in ERB template are now filled in and the template gets "translated" into HTML
Why not just the Local Variables, but Instance Variables for Controller's Actions?
Local variables can NOT be accessed outside of the method like instance variables do
From the illustration above, variables must still be accessible out of its containing method’s scope, so they can be used in ERB template.
Consider the examples below. In Ex. 1, the value of the instance variable @var is still accessible outside of the bar method, where in Ex. 2, the value assigned from local var can’t be found beyond the scope of baz method: