method

attribute_will_change!

attribute_will_change!(attr_name)
private

Dispatch target for *_will_change! attribute methods.

1Note

Use this for validatating nested forms

THAiSi ยท Jan 26, 20112 thanks

When you create a nested form, and want the main object to validate all nested models, you should make all the nested models dirty or validations will not run upon them.

class Order < ActiveRecord::Base
has_many :order_lines
accepts_nested_attributes_for :order_lines

before_validation :mark_order_lines_as_changed

private
def mark_order_lines_as_changed
  order_lines.each(&:updated_at_will_change!)
end
end