Reputation: 47086
Ruby instance variables are accessible to a single object. But in rails, if I declare an instance variable in a controller, it is still accessible in the views. What is the architecture behind this?
Upvotes: 2
Views: 368
Reputation: 6417
Well, your controller calls render
which renders your templates. So, the template code is being run within the scope of the controller instance. Therefore, you can use any instance variables declared.
Upvotes: 7