Let's assume that books belong to many categories and categories have many books. This is the Many-to-Many relationship method. A typical class would look like the following:
class Book include Mongoid::Document has_and_belongs_to_many :categories end class Category include Mongoid::Document has_and_belongs_to_many :books end
It takes all the standard options such as
:order. It also supports the
:after_remove relation callbacks.
A Many-to-Many relation cannot be a part of a polymorphic relation. This is because a polymorphic relation expects an explicit parent-child relationship and Many-to-Many ...