Active Record Querying HABTM

I am new to rails and stuck on one Querying issue. Here is the
situation.

Model: Category
class Category < ActiveRecord::Base
       has_and_belongs_to_many :postings
       has_and_belongs_to_many :volunteers
end

Model: Posting
class Posting < ActiveRecord::Base
       has_and_belongs_to_many :categories
end

Model: Volunteer
class Volunteer < ActiveRecord::Base
       has_and_belongs_to_many :categories
end

Sounds like you want a "has_many :through" relationship.

-Dave

Solution:

http://stackoverflow.com/questions/10983337/active-record-querying-rails-3-2-1