Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
只是想知道 Rails 中是否有一种方法可以识别保存表单时嵌套属性是否已更改?
例如:我有一个名为“shop”的模型,其中包含用于交付区域的嵌套复选框。
每次“商店”发生变化时,我都想知道那些嵌套的“送货区域”属性是否发生了变化。有任何想法吗?
只需添加_changed?到属性以查看它是否更改:
_changed?
my_shop.delivery_areas.first.some_checkbox_changed?
它将返回 true 或 false