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"

And in the view page I am looping it and displaying it like this

     @mem.each do |m|
                 <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>

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@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/278fe7ab10e92bab4b5a3d49ea0c8bba%40ruby-forum.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
postedSep 6, '13 at 2:51p
activeSep 6, '13 at 2:51p

1 user in discussion

Ruby rails: 1 post



site design / logo © 2022 Grokbase