Sign in through GitHub

Please read for an updated status on RailsCasts:

Learn more or hide this

Marnen Laibow-Koser's Profile

GitHub User: marnen

Site: http://marnen.livejournal.com

Comments by Marnen Laibow-Koser

Avatar

I use both Cells and Draper. They're entirely different.

Avatar

Update: I finally found a use case for Draper. I had a method that would choose a CSS class name for a particular model. It was too model-specific to put it in a helper, but too presentation-specific to feel good about putting it in the model. A presentation decorator turned out to be a good solution.

Avatar

I completely agree with you. This breaks MVC and should not be used. A pity, since I like the idea -- just not the execution.

Avatar

...and looking at the 'cast again, I'm further conflicted. I'd be inclined to put something like avatar_name in its own partial (or even helper), but neither is satisfactory from an OO point of view, as I mentioned already. At the same time, I wouldn't want to put that much HTML generation in the model, I think, and Cells, while very promising, seems to be trying to solve a different problem (though I could well be wrong). Hmm.

Avatar

Doesn't that logic go in the model?

Avatar

How is putting something in the decorator any better than putting it right in the model class? The Presenter pattern is designed to abstract display logic from one (or several) model objects whose data model isn't much like the view. That's not what's going on here, as far as I can tell. Looks rather like you're reinventing helpers.

Now, there may be some call for doing that: as you point out, helpers are among the least satisfactory parts of Rails from an OO design perspective. But I tend to think this is not the right solution to that problem.

OTOH, I usually trust you, so I'm interested in hearing more about your rationale here.