I have an incident model and a pupil model, and they have a many to
many relationship through an involvement model. Also, a pupil belongs
to a cohort.
How can I show incidents (ideally just once), in date order, where
there is an involvement present from a pupil where their
pupil.cohort_id == 1 ?
At the moment, I'm finding all pupils where pupil.cohort_id ==1, then
iterating through the @pupils, listing the involvements/incident
details for those pupils. But this isn't great, as (i) incidents show
up more than once where two pupils are involved in the incident, and
(ii) I can't order by incident date. It feels backwards.
I suspect maybe I can use
@incidents = Incident.find(:all)
@incidents = @incidents.select {|i| ... something something to do with
involvements then pupil.cohort_id == 1?
Maybe I'm miles off?
Help or clues appreciated.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---