John, I concur completely on the silliness of the "no tables" movement. This is tabular data, and it's terrifically simpler to use a <table> for it than to cobble together some CSS divs that I have to style relentlessly.
The will_filter gem looks promising for another issue I'm trying to tackle, so thanks for the point-out! Chris On Mon, Sep 17, 2012 at 11:45 AM, John Lynch <[email protected]> wrote: > Chris, > > To start with, I would say that if you are displaying tabular data, > then you *should* be using an HTML table. The whole "don't use tables" > meme was more about mis-using them in a page layout context. > > As to your question, I don't see a problem with looping through the > collection multiple times. The biggest issue I could see is if the > collection was too large to fit in memory, but that doesn't seem to be > the case as you can't really have that many columns just from a UX > perspective. > > Lastly, I've used will_filter [https://github.com/berk/will_filter] in > the past and its got some nice features, if this is an admin-type > feature you are building. (I'm not sure how hard it would be to make > it do what you want, but I thought I'd mention it anyway.) > > > Regards, > > John Lynch > [email protected] > > > > > On Mon, Sep 17, 2012 at 11:15 AM, Chris McCann <[email protected]> > wrote: > > SD Ruby, > > > > I'm wrestling with a view that displays data from a collection of model > > objects in an HTML table with the data from each model instance shown in > a > > column. I sense there's an elegant way to do what I'm trying to do but > I'm > > at a loss as to how. > > > > The markup below shows how the end result should look. What I'm trying > to > > avoid is having to look through the collection of instances to build each > > row. > > > > <div class="summary"> > > <table> > > <tr> > > <th class="first"><a href="#">Summary</a></th> > > <!-- loop through collection and write this data for each instance > --> > > <th><a href="#">201 First St.</a></th> > > <th><a href="#">1133 Columbia St.</a></th> > > </tr> > > <tr> > > <td class="first">Start Date</td> > > > > <!-- loop through collection and write this data for each instance > --> > > > > <td>01/01/2010</td> > > <td>01/01/2010</td> > > </tr> > > <tr> > > <td class="first">Term</td> > > > > <!-- loop through collection and write this data for each instance > --> > > > > <td>84 Months</td> > > <td>84 Months</td> > > </tr> > > </table> > > </div> > > > > > > Is there a better, more Railsy approach that I'm just not seeing? The > > actual table is much more complex than what's shown here so I don't want > to > > go the CSS-only no table route unless there's a really nice solution that > > entails not using tables. > > > > Cheers, > > > > Chris > > > > -- > > SD Ruby mailing list > > [email protected] > > http://groups.google.com/group/sdruby > > -- > SD Ruby mailing list > [email protected] > http://groups.google.com/group/sdruby > -- SD Ruby mailing list [email protected] http://groups.google.com/group/sdruby
