1

所以这里是问题:

语境:

  • 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 更改和轮胎的回调存在冲突......

4

1 回答 1

0

问题与这个有关=> https://stackoverflow.com/questions/14860594/issue-with-sti-nested-attributes-mongoid-3-0-22

现在似乎解决了。

于 2013-02-26T20:21:01.780 回答