On Tue, Aug 11, 2009 at 12:43 PM, karthik k <[email protected]> wrote:

>
>
> On Tue, Aug 11, 2009 at 12:36 PM, Sijo Kg <
> [email protected]> wrote:
>
>>
>> Hi Karthik
>>
>>  For example consider this
>>
>> data_array = []
>> Contract.all.each do |c|
>>  data_array << [c,c.agencies]
>> end
>>
>>    Now in view you can iterate thru this like
>>
>> data_array.each do |arr|
>>  puts arr[0].name
>>  arr[1].each do |sub_arr|
>>  puts sub_arr.name
>>  end
>> end
>>
>>        You can modify this according to your needs May be there some
>> other easier methods
>>
>>
>> Sijo
>>
>
> Hi Sijo
>
> Thank you Thank you
>
> Great Thank you
>
> --
> Karthik.k
> Mobile - +91-9894991640
>

hi sijo

I did and got the output

<table  align="center" width="50%" bordercolor="#000000">
            <% @data_array.each do |arr|%>
              <tr align="left" bgcolor="#0BA3C0">
               <% if arr[1].length>0%>
                  <th><%=  arr[0].name%></th>
                <%end%>
                </tr>
                <%for sub_arr in arr[1]%>
              <tr>
                  <td><%= sub_arr.name%></td>

              </tr>

              <%end%>
<%end%>

for the above table i am getting output as

e.g
contract1
    agency1
    agency2
contract2
   agency1
   agency2

Can i get in the below format

contract1
agency1   agency2

contract2
agency1   agency2
agency3

I dont know how to split from  <%for sub_arr in arr[1]%>

Plz help

-- 
Karthik.k
Mobile - +91-9894991640



>
>
>
>>
>> --
>> Posted via http://www.ruby-forum.com/.
>>
>> >>
>>
>
>
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" 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/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to