所以这里是问题:
语境:
- mongoid (2.2.6)
- 轮胎 (0.5.1)
类:
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 更改和轮胎的回调存在冲突......