【发布时间】:2020-08-14 23:54:58
【问题描述】:
在我的 Rails 6 应用程序中,我有这个关联:
class Project < ApplicationRecord
has_many :tasks, :dependent => :destroy, :autosave => true
accepts_nested_attributes_for :tasks, :allow_destroy => true
end
现在,当我将 project 与其嵌套的 tasks 一起保存时,这些任务只有在它们的至少一个属性发生变化时才会更新。
由于特定于我的应用程序/用例的原因,我希望tasks 始终在数据库中更新,尽管(即使它们都没有改变!)当我点击保存。
如何做到这一点?
我希望添加 :autosave => true 会有所作为,但不幸的是它没有。
【问题讨论】:
标签: ruby-on-rails ruby activerecord nested-forms