Class: AdminAssistant::Request::CreateSaving
Instance Attribute Summary collapse
#record
Instance Method Summary
collapse
#record_and_associations_valid?, #redirect_after_save
Constructor Details
#initialize(record, controller, params_prefix = nil) ⇒ CreateSaving
Returns a new instance of CreateSaving.
41
42
43
44
|
# File 'lib/admin_assistant/request/create.rb', line 41
def initialize(record, controller, params_prefix = nil)
super record, controller
@params_prefix = params_prefix
end
|
Instance Attribute Details
#params_prefix ⇒ Object
Returns the value of attribute params_prefix.
39
40
41
|
# File 'lib/admin_assistant/request/create.rb', line 39
def params_prefix
@params_prefix
end
|
Instance Method Details
#blank? ⇒ Boolean
46
47
48
|
# File 'lib/admin_assistant/request/create.rb', line 46
def blank?
raw_params.values.all? &:blank?
end
|
#params_for_save ⇒ Object
50
51
52
|
# File 'lib/admin_assistant/request/create.rb', line 50
def params_for_save
ParamsForSave.new @controller, @record, raw_params
end
|
#prepare_record_to_receive_invalid_association_assignments ⇒ Object
54
55
56
|
# File 'lib/admin_assistant/request/create.rb', line 54
def prepare_record_to_receive_invalid_association_assignments
end
|
#raw_params ⇒ Object
58
59
60
61
|
# File 'lib/admin_assistant/request/create.rb', line 58
def raw_params
model_class_symbol = @record.class.name.underscore.to_sym
@controller.params[model_class_symbol][@params_prefix]
end
|
#save ⇒ Object
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/admin_assistant/request/create.rb', line 63
def save
if @controller.respond_to?(:before_create)
@controller.send(:before_create, @record)
end
result = super
if @controller.respond_to?(:after_create)
@controller.send(:after_create, @record)
end
result
end
|