I have a model Widget, with several subclasses:
Widget
Checkbox
Textbox
SelectMenu
…
Each of these models represent something that will be displayed to the
user. For example, I want a checkbox to output . 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?
Thanks,
Dana P