Rails 5 - 多态与自动保存无法正常工作

时间:2016-10-27 15:16:51

标签: ruby-on-rails

在我的应用程序中,我有一个与Annotation和Document有多态关系的Tag模型。

代码

belongs_to :tagable, :polymorphic => true

注释

has_many :tags, :as => :tagable, dependent: :destroy, autosave: true

文档

belongs_to :tagable, :polymorphic => true, autosave: true

然而自动保存不起作用。我做错了什么?

1 个答案:

答案 0 :(得分:0)

自动保存不会导致问题;这需要使用嵌套表单accepts_nested_attributes_forreject_if实现。