1

Just wondering if there's a method in rails to identify if nested attributes have been changed when a form is saved?

Eg: I have a model called 'shop', which has nested check boxes for delivery areas.

Each time 'shop' is changed, I'd like to know if those nested 'delivery area' attributes where changed. Any ideas?

PlankTon
  • 12,443
  • 16
  • 84
  • 153

1 Answers1

2

just add _changed? to attribute to see if it changed:

my_shop.delivery_areas.first.some_checkbox_changed?

It'll return true or false

fl00r
  • 82,987
  • 33
  • 217
  • 237