models that know how to display themselves

I have a model Widget, with several subclasses:

Each of these models represent something that will be displayed to the
user. For example, I want a checkbox to output <input type="checkbox"
id="whatever" />. My question is, where should the display code for
each model go? The model seems like the best place to me, because it
keeps all code related to that particular Widget together. However,
that obviously breaks the rules. I've considered having helper methods,
but then I end up with a huge, ugly if/else tree (I might have 10-20
different types of Widgets).

What's the Rails way of handling a problem like this?


Dana P

I have a surprisingly similar group of models on one of my projects. I
just have a family of really small _partials that they all call as

danajp[at]gmail[dot]com wrote: