1
なぜhas_manyを使用して複数回レコードをプッシュできないのですか?Mongoidでhas_manyを使用して重複レコードをプッシュできないのはなぜですか?
class Template
include Mongoid::Document
has_and_belongs_to_many :widgets, inverse_of: nil
重複を追加しようとしています。
(rdb:387) self.widgets.push(Widget.first)
[BSON::ObjectId('4f7096776c51c8135000000d')]
(rdb:387) self.widgets.push(Widget.first)
[BSON::ObjectId('4f7096776c51c8135000000d')]
(rdb:387) self.widgets.count
1
なぜinverse_of:nilを定義しましたか?なぜhbtmを使用しないのであれば? – shingara