私は3つのモデルを持っています:
class Interest
include Mongoid::Document
has_many :user_hobby
end
class UserHobby
include Mongoid::Document
field :contacts, :type => Array
belongs_to :interest, :foreign_key => "interest", inverse_of: nil
belongs_to :interest, :foreign_key => "related_interests", inverse_of: nil
embedded_in :user
end
class User
include Mongoid::Document
embeds_many :user_hobby
end
user と user_hobby の間に埋め込み関係を追加する必要がありますが、その後 (私のテストでは) 興味を保存したいときにこのエラーが発生します:
Mongoid::Errors::MixedRelations: UserHobby が埋め込まれているため、リレーショナル アソシエーションを介して Interest ドキュメントから UserHobby ドキュメントを参照することはできません。
このトピックを見ましたが、あまり役に立ちませんでしたMongoid::Errors::MixedRelations
ありがとう。