Testing table associations

First, thanks to everyone who replied to my pluralization question
from before! Today I’m confused by associations. I’ve set up a bunch
of associations in my models to describe these relationships:

  • each user can have many bookmarks and tags
  • each bookmark can have many users and tags
  • each tag can have many bookmarks and users

(Part of what is confusing is that I can change the wording to “each
bookmark BELONGS TO many users and tags” and it still sounds
‘correct’ when you read it. But does that mean I’m supposed to use
belongs_to instead of has_many?? I know they’re completely different!)

To do this I have four tables: users, bookmarks, tags, and a table
for doing the lookups called “matchups”. The first three tables are
simple, normalized lookup tables. Each row has an item and a unique
id, that’s it, like this:
bookmarks:“23 => www.cnn.com
users:“7 => scott”
tags:“44 => news”

The matchups table has 4 columns, id, bookmark_id, user_id, & tag_id.
Example record from matchups:
id:1 bookmark_id:23 user_id:7 tag_id:44

The purpose of the matchups table is to find out things like who owns
which bookmarks and tags, and which tags have what bookmarks, and
other similar queries. What I’d like to do is get a listing of
records from the matchups table and not have the id numbers littering
the screen. I want the id numbers to be looked up in their
corresponding tables & replaced with the value they point to, like
printing “news” instead of “44”.

My models are:
root (634) $ cat bookmark.rb user.rb tag.rb matchup.rb
class Bookmark < ActiveRecord::Base
has_many :users, :through => :matchups
has_many :tags, :through => :matchups
end
class User < ActiveRecord::Base
has_many :bookmarks, :through => :matchups
has_many :tags, :through => :matchups
has_many :events
end
class Tag < ActiveRecord::Base
has_many :bookmarks, :through => :matchups
has_many :users, :through => :matchups
end
class Matchup < ActiveRecord::Base
end

(Should I be using HABTM instead of the has_many :through??)

What syntax should I use to test these relationships out? Should I
test in the console or in a view? All advice would be very
appreciated.Sorry this is so long, but I figured better more info
than less…

Thanks!
-Jason