I need to read the number of times that tag_id shows up in the listings_tags db table. Tags are entered into the system via the Listings form. I have a page that lists just tags.
current
tag1()
tag2()
tag3()
tag4()
Desired
tag1(40)
tag2(22)
tag3(5)
tag4(4)
code that may be relevant
schema
create_table "listings_tags", :id => false, :force => true do |t|
t.integer "listing_id"
t.integer "tag_id"
end
create_table "tags", :force => true do |t|
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
end
class Tag < ActiveRecord::Base
has_and_belongs_to_many :listings
validates_uniqueness_of :name
class Listing < ActiveRecord::Base
belongs_to :profile
has_and_belongs_to_many :tags