Forum: Ruby on Rails Views Question / Problem

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
4bfccddd9228cc2e8a00005af679475a?d=identicon&s=25 John Burm (funbags)
on 2007-01-31 04:56
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
C4dc94c893471878a105761a9207f29b?d=identicon&s=25 Zack Chandler (Guest)
on 2007-01-31 05:35
(Received via mailing list)
On 1/30/07, John Burm <rails-mailing-list@andreas-s.net> wrote:
>
> There are currently 5 product_types, however a few more may be added in
> 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
4bfccddd9228cc2e8a00005af679475a?d=identicon&s=25 John Burm (funbags)
on 2007-01-31 06:54
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.com


I 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
This topic is locked and can not be replied to.