1

だからここに問題があります:

環境:

  • モンゴイド(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 に答える