Tables:
booking: show_id (belongs_to: show)
show: name, venue_id (has_many :bookings belongs_to :venue)
venue: location, capacity ( has_many : shows)
NOW, I use this view,
Listing venue rank
<% @bookings.each do |booking| %> <%=h booking.show.venue.location %>
<br />
</tr></table>
it can get the booking venue list like that :
Listing venue rank
Location: www
Location: www
Location: weee
Location: weee
Location: www
but I want 2 make this page like that:
Listing venue rank
Location: www 3
Location: weee 1
I want to count the dupliate locations and show the number. I think it
will use distinct or count to modfy the controllers, but i do not figure
out. please give me some sugguestion.
class ShowsController < ApplicationController
def index
@shows = Show.find(:all, :order => "date")
@venue = Venue.find(:all)
class BookingsController < ApplicationController
def index
@bookings = Booking.find(:all, :order => “show_id, date”)
@venue = Venue.find(:all)
@shows = Show.find(:all)
class VenuesController < ApplicationController
def index
@venues = Venue.all