Class: AdminAssistant::Request::AbstractNew

Inherits:
Base
  • Object
show all
Defined in:
lib/admin_assistant/request/new.rb

Direct Known Subclasses

MultiNew, SingleNew

Instance Method Summary collapse

Methods inherited from Base

#action, #after_template_file, #before_template_file, #initialize, #model_class, #model_class_symbol, #origin, #render_multi_form, #render_single_form, #render_template_file, #render_to_string, #render_to_string_if_exists

Constructor Details

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

Instance Method Details

#new_savingObject



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/admin_assistant/request/new.rb', line 4

def new_saving
  saving = CreateSaving.new model_class.new, @controller
  @admin_assistant.form_settings.columns_for_new.each do |column|
    if block = @admin_assistant.form_settings[column].default
      saving.record.send("#{column}=", block.call(@controller))
    end
  end
  if @controller.params[model_class_symbol]
    saving.record.attributes = saving.params_for_save
  end
  saving
end