Updating records in a many-to-many relationship

Im trying to establish relationships in a many to many table.

When I create a user, I do this to insert the different relationships
between the user and sports:

c.sports<<Sport.find_all_by_name(params[:sports])

where c is the user. The problem is, when I edit this user, and lets say
he adds a sport, I can’t use this because I get an error saying that
some records already exist since its not only adding the new records but
also all the old records again.

What is the best way to do an updating like this is rails?

Should I just delete all the records associated with the user and add
them in again?

Check out http://hasmanythrough.rubyforge.org/

I took a look at that site, its doesnt talk about how to handle updating
of data with ruby’s built in many-to-many feature, the one where you set
a table A_B for table A and B.

Bala P. wrote:

Check out http://hasmanythrough.rubyforge.org/