In rails 4 I have a many to many relationship with an intermediate table in the database and has_and_belongs_to_many in each model referring to each other
The relationship looks like this...
tags >--- posts_tags ---< posts
right now I have an html form that a user uses to create a new post and the id's of their chosen tags are getting uploaded as an array named tags[]
My question is whats the best way to add all these posts_tags to the database? I realize I can just foreach through the tag id's and use Tag.find to retrieve those models but that will be alot slower than a single insert query that inserts the post id and each tag id into the post_tags column for each tag added. I also would prefer to do this the active record way to keep things short and clean.