has/belongs to many sql error

Pretty sure the id is your problem, remove it and I bet all will be well.

you can do this in your migrations:

create_table :my_table_name, :id => false do |t| ... ... end

to avoid the id on join tables in the future

good luck! Tim