Has_many with :through question

This is my first independent RoR project after working with recipes
from some cool books that I’ve been reading…

Background: I’m building an app that could potentially useful to
college students. The idea is that between semesters, students at a
given campus would list textbooks that they have and textbooks that
they need and the app would match them up (if I have what you want and
you have what I need, its a match).

So, here are the models I’ve defined so far: Book, User, WantedOffer
and NeedOffer. A book that is offered will have an additional
attribute, such as, “condition” (new, used, like new, etc).

Class User < ActiveRecord::Base
has_many wanted_offers
has_many have_offers
has_many books :through => wanted_offers, :have_offers
end

Class Book < ActiveRecord::Base
has_many wanted_offers
has_many have_offers
has_many users :through => wanted_offers, :have_offers
end

Class HaveOffer < ActiveRecord::Base
belongs_to :book
belongs_to :user
end

Class WantedOffer < ActiveRecord::Base
belongs_to :book
belongs_to :user
end

I don’t know if “:through => wanted_offers, :have_offers” is a valid
call (I’m looking into it) but at least now, it makes the model
relationships work in my mind :slight_smile: I can get to users from books via
have_offers and wanted_offers and visa versa.

It also looks like I need a :dependent => :destroy calls somewhere
since WantedOffer and HaveOffer don’t make sense without a Book. I’m
not sure where to put this just yet…

Thanks in advance for the help…