method
attribute_will_change!
v3.0.0 -
Show latest stable
-
1 note -
Class: ActiveModel::Dirty
- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3
- 2.1.0
- 2.2.1
- 2.3.8
- 3.0.0 (0)
- 3.0.9 (-13)
- 3.1.0 (0)
- 3.2.1 (0)
- 3.2.8 (0)
- 3.2.13 (0)
- 4.0.2 (0)
- 4.1.8 (0)
- 4.2.1 (0)
- 4.2.7 (0)
- 4.2.9 (0)
- 5.0.0.1 (4)
- 5.1.7 (0)
- 5.2.3 (0)
- 6.0.0 (38)
- 6.1.3.1 (0)
- 6.1.7.7 (0)
- 7.0.0 (0)
- 7.1.3.2 (0)
- 7.1.3.4 (0)
- What's this?
Register or
log in
to add new notes.
THAiSi -
January 26, 2011 - (>= v3.0.0)
2 thanks
Use this for validatating nested forms
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