On Mar 1, 2010, at 10:18 PM, François Beausoleil wrote:

Hi all!

I have events, event kinds and companies:

Company has_many :events
Event belongs_to :company
Event belongs_to :event_kind

I'm generating a report sheet / progress chart for my users. Rows are
companies, and columns are event kinds. My code is ugly, but works. I
want to beautify it. Here's the current look (SPOILER: ugly, ugly,
ugly): http://gist.github.com/319083

<table-plus with="&@companies" fields="&@fields">
 <event-kind-1-heading-link:>
   <%=h @event_kinds.detect {|ek| ek.id == 1}.name %>
 </event-kind-1-heading-link:>
 <event-kind-1-view:>
   <a if="&this" with="&@events[this.to_i]"><%= this ?
this.created_at.to_date.to_s(:short) : nil %></a>
 </event-kind-1-view:>

 <event-kind-2-heading-link:>
   <%=h @event_kinds.detect {|ek| ek.id == 2}.name %>
 </event-kind-2-heading-link:>
 <event-kind-2-view:>
   <a if="&this" with="&@events[this.to_i]"><%= this ?
this.created_at.to_date.to_s(:short) : nil %></a>
 </event-kind-2-view:>
</table-plus>

This is all boiler plate. I'm sure I can automatically generate this.
If I were using plain jane Rails, I'd have a partial to which I'd pass
options. My problem stems from the fact that table-plus expects to
have child attributes which match the field names. Notice I have a
@fields ivar which at least tells me which columns are expected.

So? How can I programatically generate columns for table-plus?

In this case, I think you're fighting an uphill battle trying to feed this to table-plus; you're probably better off writing your own tag from scratch, as it will certainly be clearer and easier to debug.

--Matt Jones

--
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/hobousers?hl=en.

Reply via email to