mongoid has_many дети не сохраняются через nested_attributes, когда включены Tire::Callbacks
Итак, вот проблема:
контекст:
- монгоид (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
кажется, что есть конфликт с автосохранением с изменением nested_attributes на mongoid и обратными вызовами шины...
1 ответ
Решение
Проблема была связана с этим => https://stackru.com/questions/14860594/issue-with-sti-nested-attributes-mongoid-3-0-22
Теперь это кажется решенным.