Hi I have has_and_belongs_to_many
relationship between Posts and Comments and in my edit action I have form that returns me list of ids 1,3,5,8
etc. I want build relationship between my current model and all models which ids are in the list so @post.comments
will return Comments with 1,3,5,8
ids
In fact I need execute
DELETE FROM comments_posts
WHERE post_id = @post.id
INSERT INTO comments_posts VALUES
(1,@post.id)
(3,@post.id)
(5,@post.id)
(8,@post.id)
or do something similar