I'm also a newbie. Here's how I do it:
There is a technique called habtm -- has and belongs to many.
I am not going to show you habtm, because I don't use it. Habtm describes the trivial situation where the pivot table contains only ids from the two tables it joins. You may find you want other data in your join table besides just those two ids, and thus you would use the method I am describing. It is in the section in Agile Rails Development called "Using Models as Join Tables".
You make what's called a "pivot table", or an "intermediate join table". It is a table that sits between your two tables. At the very least, it has an id from each table. Your model would be called
user_file
your table would be called
user_files
and it would consist of
user_id file_id
but could have other columns as well.
Then, in your user_file model, you have these lines:
belongs_to :user belongs_to :file
(notice the pluralization -- when you talk about a model on the "one" side of a one-to-many relationship, it's singular - -on the many side, it's plural)
in your user model, you have these lines
has_many :user_files has_many :files, :through => :user_files
and your user table must have, at the very least, these columns:
id user_file_id
then of course in your file model, you have
has_many :user_files has_many :users, :through => :user_files
and your file model must have, at the very least, these columns
id user_file_id
And rails style says that all these id columns should be integers, but if you want to fight that, there are ways.
That's it, good luck.
Charlie