On Sep 17, 2012, at 11:15 AM, Chris McCann <[email protected]> wrote:

> 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.

I don’t know about Railsy, but if you’re concerned with the 
elegance/readability/beauty/whatever of the code, given what you say about the 
complexity of the output, you might want either a helper or perhaps a presenter 
instance (i.e. an object that contains the logic for the display) to take care 
of each of the rows.

Then the complex part of your view code might look something like:
<% row_helpers = %i{row1helper row2helper row3helper} %>
<tr>
<%= row_helpers.map do |h|
        self.send h, row_data
end * ‘</tr><tr>’ %>
</tr>

Here I’m multiplying a string array by a string to get the array joined using 
that string, and using the new %i syntax to get an array of symbols.

If your concern is speed of execution rather than eloquence, you might not want 
to go this route though.

-- 
SD Ruby mailing list
[email protected]
http://groups.google.com/group/sdruby

Reply via email to