Hello,

I am trying to insert elements into an array like this...

@mem = []@tran = Transport.find_all_by_month_and_vehicle(date,vehicle)tran.each 
do |t|
  @mem << [Student.find_by_id(t.mem_id), t.transport_date, vehicle.no] if 
t.mem_type=="Student"
  @mem << [Employee.find_by_id(t.mem_id), t.transport_date, vehicle.no] if 
t.mem_type=="Employee"end

And in the view page I am looping and displaying it as

@mem.each do |m|
  <tr>
            <td><%= link_to m[0].first_name} %></td>
            <td > <%= m[0].age %></td>
            <td id="date"> m[1] </td>
            <td id="vehicle"> m[2] </td>
  </tr><%end%>

But I am getting duplicate entries in the table... So I neeed to remove 
duplicates and display only unique values.. I tries doing 
  @mem << [Student.find_by_id(t.mem_id), t.transport_date, vehicle.no].uniq! if 
t.mem_type=="Student".. But it is not working.. Please help


-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/bb65bdc3-1a10-4139-9c98-103b5dddda4b%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to