我有一个带有创建关联记录的 after_create 过滤器的简单模型。
class Subject
after_create :create_topics!
has_paper_trail :on => [:create, :update],
:ignore => [:topics]
private
def create_topics!
self.account.default_topics_for_subject_type(self.subject_type).each do |topic|
self.topics.create!({:name => topic.name})
end
end
end
然而,创建Subject
例如将创建两个主题的 now 会导致同一主题的两个版本,即主题更改create
之前和之后的版本。update
关于如何解决这个问题的任何想法?
更新
主题模型不是主题的子类,而是属于它。它们也有一个 paper_trail 并且应该从创建过程的开始到主题进行版本控制。
class Topic
belongs_to :subject
end