On Jan 19, 2011, at 3:10 PM, Aleks Clark wrote:
> I'm working up a table view, and have run into this problem:
>
> I'm iterating over a collection of objects. In each iteration, I want
> to iterate over a separate, unassociated collection of other objects,
> but inside the second iteration, I need to access the parent context,
> and I can't find anything that would let me do that. this_parent
> doesn't want to work because the second iteration set is unassociated.
> like so:
>
> <append-tr:> <-- I'm accessing the first iteration set via the <table> tag
> <repeat with="&@goals">
> <td>(here I need to access attributes of the collection <table> is
> working on AND attributes of the individual @goals)</td>
> </repeat>
> </append-tr:>
>
> how would I accomplish this? is there some way I can pass the
> attribute down the chain? something like
>
> <repeat with="&@goals" send-attr-as-blah="@parent.attr">
> <td><this.blah><this.other_stuff></td>
> </repeat>
This is going to get confusing with just DRYML (you really have two "current
objects"), so you might want to just fall back to ERB:
<append-tr:>
<% @goals.each do |goal| %>
do stuff - object for the table row is in 'this', goal is in 'goal'
<% end %>
</append-tr:>
--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.