Skip to content

Commit 8421fc9

Browse files
committed
Fix the instance of template object in closure
1 parent 1ddb53e commit 8421fc9

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

lib/active_admin_import/dsl.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,12 @@ def active_admin_import options = {}, &block
3333
headers_rewrites: {}
3434
}
3535
options = default_options.deep_merge(options)
36-
options[:template_object] = ActiveAdminImport::Model.new if options[:template_object].blank?
37-
params_key = ActiveModel::Naming.param_key(options[:template_object])
36+
params_key = ActiveModel::Naming.param_key(options[:template_object] || ActiveAdminImport::Model.new)
3837

3938
collection_action :import, method: :get do
4039
authorize!(ActiveAdminImport::Auth::IMPORT, active_admin_config.resource_class)
4140

42-
@active_admin_import_model = options[:template_object]
41+
@active_admin_import_model = options[:template_object] || ActiveAdminImport::Model.new
4342
render template: options[:template]
4443
end
4544

@@ -52,7 +51,7 @@ def active_admin_import options = {}, &block
5251
collection_action :do_import, method: :post do
5352
authorize!(ActiveAdminImport::Auth::IMPORT, active_admin_config.resource_class)
5453

55-
@active_admin_import_model = options[:template_object]
54+
@active_admin_import_model = options[:template_object] || ActiveAdminImport::Model.new
5655
@active_admin_import_model.assign_attributes(params[params_key].try(:deep_symbolize_keys) || {})
5756
#go back to form
5857
return render template: options[:template] unless @active_admin_import_model.valid?

0 commit comments

Comments
 (0)