I have a Ticket.rb model, and School.rb model.
Ticket belongs_to
School
School has_many
Tickets
How can I use ActiveRecord to find out total .count
of how many Tickets each School has?
I'm aware that Ticket.where(:school_id => -insert School ID here-).count
will give me the individual count of each school but I'm using this to populate the data into a graph so I really need something more like School.tickets.count
.
Is this possible without messing up my associations?
Thanks all..