A simple has_and_belongs_to_many
association:
Person has_and_belongs_to_many :products
Product has_and_belongs_to_many :persons
Ar
You just need one, unless you are doing unique
add_index :person_products, :person_id
add_index :person_products, :product_id
Or for an index on both columns
add_index :person_products, [:person_id, :product_id]
This will help performance when querying on those columns on the database. It will depend on your query if it includes both columns or just one.
http://apidock.com/rails/ActiveRecord/ConnectionAdapters/SchemaStatements/add_index