In a join table, what’s the best workaround for Rails’ absence of a composite key?
Add a unique index that includes both columns. That will prevent you from inserting a record that contains a duplicate category_id/post_id pair. add_index :categories_posts, [ :category_id, :post_id ], :unique => true, :name => ‘by_category_and_post’