Class: AdminAssistant::Request::Update::Saving

Inherits:
AbstractSaving show all
Defined in:
lib/admin_assistant/request/update.rb

Instance Attribute Summary

Attributes inherited from AbstractSaving

#record

Instance Method Summary collapse

Methods inherited from AbstractSaving

#initialize, #params_for_save, #record_and_associations_valid?, #redirect_after_save

Constructor Details

This class inherits a constructor from AdminAssistant::Request::AbstractSaving

Instance Method Details

#prepare_record_to_receive_invalid_association_assignmentsObject



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/admin_assistant/request/update.rb', line 38

def prepare_record_to_receive_invalid_association_assignments
  params_for_save.errors.each_attribute do |attr|
    @record.instance_eval <<-EVAL
      @attempted_attributes ||= {}
      def #{attr}=(ary)
        @attempted_attributes[#{attr.inspect}] = ary
      end
      def #{attr}; @attempted_attributes[#{attr.inspect}]; end
    EVAL
  end
end

#saveObject



50
51
52
53
54
55
# File 'lib/admin_assistant/request/update.rb', line 50

def save
  if @controller.respond_to?(:before_update)
    @controller.send(:before_update, @record)
  end
  super
end