-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
None
I have just upgraded to Mongoid 3.0x in my new project and a few things have broken.
One in particular is my has_and_belongs_to_many relationship used to have an 'as' clause but now that doesn't work.
How should I implement models where (for example) a Band can have both musicians and fans? I tried something like this but it's not right. The docs are alas out of date in this respect.
class Band
include Mongoid::Document
field :name, type: String
has_and_belongs_to_many :musicians, as: :member_of, class_name: "User"
has_and_belongs_to_many :fans, as: :fan_of, class_name: "User"
end
class User
include Mongoid::Document
field :name, type: String
has_and_belongs_to_many :bands, as: :member
has_and_belongs_to_many :bands, as: :fan
end
Sorry if this is a noob question, today is my first day with MongoDB and Mongoid.