Skip to content

Commit 4419b68

Browse files
committed
Added parameter with col_sep
1 parent 9330497 commit 4419b68

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

app/views/admin/import.html.erb

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
<p class="active_admin_import_hint">
2-
<%= raw(@active_admin_import_model.hint) %>
2+
<%= raw(@active_admin_import_model.hint) %>
33
</p>
44
<%= semantic_form_for @active_admin_import_model, url: {action: :do_import}, html: {multipart: true} do |f| %>
55
<%= f.inputs name: t("active_admin_import.details") do %>
66
<%= f.input :file, as: :file %>
7+
<%= f.input :col_sep, collection: [';', ','], include_blank: false, selected: ';' %>
78
<% end %>
9+
810
<%= f.actions do %>
911
<%= f.action :submit, label: t("active_admin_import.import_btn"), button_html: {data: {disable_with: t("active_admin_import.import_btn_disabled")}} %>
1012
<% end %>
11-
<% end %>
13+
<% end %>

lib/active_admin_import/importer.rb

+1
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ def detect_csv_options
172172
else
173173
options[:csv_options] || {}
174174
end.reject { |_, value| value.nil? || value == "" }
175+
@csv_options[:col_sep] = model.col_sep if model.respond_to?(:col_sep)
175176
end
176177
end
177178
end

lib/active_admin_import/model.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ def default_attributes
6565
csv_headers: [],
6666
file: nil,
6767
force_encoding: 'UTF-8',
68-
hint: ''
68+
hint: '',
69+
col_sep: ';'
6970
}
7071
end
7172

0 commit comments

Comments
 (0)