ruby rails
2013-Sep-06 14:50 UTC
Delete duplicate entries from a 2 dimensional array in ror
I am trying to loop 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 it and displaying it like this
@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 duplicates entries here..I need to remove duplicate
entries from this.. How do I do it?? Kindly help
--
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 unsubscribe from this group and stop receiving emails from it, send an email
to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/278fe7ab10e92bab4b5a3d49ea0c8bba%40ruby-forum.com.
For more options, visit https://groups.google.com/groups/opt_out.