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 <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? Thanks, Dana P --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
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 appropriate. danajp[at]gmail[dot]com wrote:> 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 <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? > > > Thanks, > > Dana P > > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---