所以这就是问题:
上下文:
类:
class Account
include Mongoid::Document
has_many :comments, auto_save: true
accepts_nested_attributes_for :comments
end
class Comment
include Mongoid::Document
include Tire::Callbacks
include Tire::Search
belongs_to :account
end
操作:
account = Account.first
account.comments_attributes = [{content: 'super'}]
account.comments => [#<Comment content: 'super'>]
问题:
Comment.count => 0
Comment.search().count => 1
account.comments.build {content: 'super'}
account.save => true
Comment.count => 1
似乎与自动保存存在冲突,在mongoid上有nested_attributes更改和轮胎的回调......
答案 0 :(得分:0)