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?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Well, your controller calls
renderwhich 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.