Creating an association in a join table

I know this one sounds sooo simple, but it’s been bugging me for hours.
I’ve got an ajax drag and drop add page, adding an item from one list to
another. I’ve got it working to the poing where it loads the action to
do the actual adding to the database but that’s where I hit a wall.

Question: how do I make an association in my habtm join table that joins
an existing category and an existing artist.

Here’s what I’ve got so far:

def add_artwork
##Security Hole???
artwork_id = params[:id].split("_")[1]
artwork = Artwork.find(artwork_id)
category = Category.find(params[:category])

categories << artwork



render :partial => "category"

end

I’m stuck on the categories<< bit, there doesn’t seem to be much
straightforward doco that just spells it out clearly.

Cheers,

Brendon