Module: ActiveModel::UpdatePermittedAttributes::ClassMethods
- Defined in:
- lib/modify_resource/rails/active_model/update_permitted_attributes.rb
Overview
Hook into models that accept nested attributes.
Instance Method Summary collapse
Instance Method Details
#accepts_nested_attributes_for(field, options = {}) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/modify_resource/rails/active_model/update_permitted_attributes.rb', line 38 def accepts_nested_attributes_for(field, ={}) before_validation do return unless @as_user.present? child = self.send(field) # Copy down the chain as needed. # As_user will be unset on both models after save. if child.respond_to? :map children = child children.map {|c| c.as_user = @as_user } else child.try(:as_user=, @as_user) end end super(field, ) end |