From: Paul Lynch Date: 2006-09-28T20:16:28+09:00 Subject: Re: Rails for the Rubyist On 27 Sep 2006, at 16:40, Phrogz wrote: > Paul Lynch wrote: >> Agile Web Development with Rails (2nd Ed) is going to be your answer, >> but I think you'd enjoy Ruby for Rails, too; I know I did. > > I just bought the PDF, and I'm not very far into it, but I've already > found this section: > > "In the description of views and controllers, we showed the controller > setting the time to be displayed into an instance variable. > The .rhtml file used > that instance variable to substitute in the current time. But the > instance data of > the controller object is private to that object. How does ERb get > hold of this private > data to use in the template? > > The answer is both simple and subtle. Rails does some Ruby magic so > that the instance variables of the controller object are injected > into the > template object. As a consequence, the view template can access any > instance > variables set in the controller as if they were its own. > > Some folks press the point: "just how do these variables get set?" > These folks clearly don't believe in magic. Avoid spending > Christmas with them." > > Very amusing, but exactly the sort of explanation and attitude that I > was hoping to avoid. Ah well; certainly other good information in > it so > far. (I'm also discouraged by the appearance that the book takes the > track of "If you use an RDBMS other than MySQL, it'll mostly work, but > you're on your own when you run into trouble.") Just for clarity, that quote is from a "Joe Asks" pull out in AWDwR, not Ruby for Rails. Joe being the archetypal newbie programmer. I think that's excusable, until we find the perfect text for explaining OOP and MVC; if anyone knows of it, I'd love to hear from you. Paul