我看到一些奇怪的行为在Mongoid 2.3.4Mongoid - 数组赋值
class Student
has_and_belongs_to_many: teachers
end
class Teacher
has_and_belongs_to_many: students
end
现在IRB
s = Student.first
s.teachers
=> []
s.teacher_ids = [Teacher.first.id, Teacher.last.id]
s.teacher_ids
=> [[BSON::ObjectId4f7c3300913417162c000008, BSON::ObjectId4f7c333b913417162c00000d]]
不知道为什么这阵嵌套类的。我预计
[BSON::ObjectId4f7c3300913417162c000008, BSON::ObjectId4f7c333b913417162c00000d]
这打破了Rails的多选择字段,在那里同样显示在IRB IDS的质量分配会发生。
为什么不升级到更新版本的mongoid? – rubish 2012-04-10 19:24:11
好吧,我会检查是否在新版本中更正了这种行为。你看到它在新版本中正常工作吗? – 2012-04-10 19:55:17
我在我的视图中有很多这样的领域,他们对我来说工作得很好。我在2.2.2以及在切换到2.4.6之后使用了它。 – rubish 2012-04-11 06:17:15