railscasts.com
02 Apr '12, 12am
I'm back to ivars in controllers for the same reason as this comment: @leshill @myronmarston @avdi
As long as we're talking theory & coupling... From the perspective of the view, it has to 'know' a priori how the controller is providing data, either instance variables or expose'd methods etc. I've been changing some controllers over to using respond_to/respond_with ala episode 224 (http://railscasts.com/episodes/224-controllers-in-rails-3). The only stumbling block for me is that the view template still needs to know how the controller is providing data, even though the controller specified 'respond_with widgets' (or 'respond_with @widgets'). Non-templated requests, e.g. /widgets/index.xml, are picking up the correct data, but I don't see a clean way of determining in the view template (say index.html.haml) what the controller said to respond_with. The real pain point here is when I'm rendering partials. At the moment I'm having to call the partial with a :locals hash. ...
Full article:
http://railscasts.com/episodes/259-decent-exposure?view=c...