I am currently in the process of creating a ecommerce site and was hoping I could ask for some feedback with the question below... Thank you in advance! Currently an order can have_many line_items. The line_items db table has many fields which may or may not be used depending on the product_type_id defined for that line_item. For example, line_item.color may be null if the product_type_id is 1, where as if it was 2 the line_item.color might be red. To keep the view clean for viewing an actual line_item I was not sure about the best way of doing this. At first glance I was thinking of creating a partial view for each product_type. (Example - _product_type_1.rhtml) Then I thought of hiding specific columns in the html table by checking to see if that field is blank to keep it all as one view. If the latter is the better idea, then what would be the best way of hiding the unused columns? There are currently 5 product_types, however a few more may be added in the future. Not to throw more into the mix, but there may be other partials to include depending upon the product_type_id as well. For example, if the product_type_id is 1 or 2 then we must include this other partial which would display the status updates for this line_item. Where was if the product_type_id was 3 there are no status updates associated with it. I would appreciate any and all suggestions, as I am not sure would would be the best / proper way of doing this. Thank you, - John -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
On 1/30/07, John Burm <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > I am currently in the process of creating a ecommerce site and was > hoping I could ask for some feedback with the question below... Thank > you in advance! > > Currently an order can have_many line_items. The line_items db table has > many fields which may or may not be used depending on the > product_type_id defined for that line_item. For example, > line_item.color may be null if the product_type_id is 1, where as if it > was 2 the line_item.color might be red. > > To keep the view clean for viewing an actual line_item I was not sure > about the best way of doing this. At first glance I was thinking of > creating a partial view for each product_type. (Example - > _product_type_1.rhtml) > > Then I thought of hiding specific columns in the html table by checking > to see if that field is blank to keep it all as one view. If the latter > is the better idea, then what would be the best way of hiding the unused > columns? > > There are currently 5 product_types, however a few more may be added in > the future. Not to throw more into the mix, but there may be other > partials to include depending upon the product_type_id as well. For > example, if the product_type_id is 1 or 2 then we must include this > other partial which would display the status updates for this line_item. > Where was if the product_type_id was 3 there are no status updates > associated with it. > > I would appreciate any and all suggestions, as I am not sure would would > be the best / proper way of doing this. > > Thank you, > - John > > -- > Posted via http://www.ruby-forum.com/. > > > >John, I think the answer depends on how much the partials are going to differ. If there are only a few differences then one partial may work. Otherwise maybe 5 would do. I would mock it out both ways and see what feels DRYer and simple. -- Zack Chandler http://depixelate.com --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
Zack Chandler wrote:> John, > > I think the answer depends on how much the partials are going to > differ. If there are only a few differences then one partial may > work. Otherwise maybe 5 would do. I would mock it out both ways and > see what feels DRYer and simple. > > -- > Zack Chandler > http://depixelate.comI am so confused on what to do, I was even considering database changes to better handle all different order types. I''ll try the one partial to start, because splitting it up after wouldn''t be hard to do anyways. Thanks Again, - John -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---