Skip to content

Commit

Permalink
Added parameter with col_sep
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanfox1985 committed Apr 16, 2020
1 parent 9330497 commit ec48635
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions app/views/admin/import.html.erb
@@ -1,11 +1,13 @@
<p class="active_admin_import_hint">
<%= raw(@active_admin_import_model.hint) %>
<%= raw(@active_admin_import_model.hint) %>
</p>
<%= semantic_form_for @active_admin_import_model, url: {action: :do_import}, html: {multipart: true} do |f| %>
<%= f.inputs name: t("active_admin_import.details") do %>
<%= f.input :file, as: :file %>
<%= f.input :col_sep, collection: [';', ','], include_blank: false %>
<% end %>
<%= f.actions do %>
<%= f.action :submit, label: t("active_admin_import.import_btn"), button_html: {data: {disable_with: t("active_admin_import.import_btn_disabled")}} %>
<% end %>
<% end %>
<% end %>
1 change: 1 addition & 0 deletions lib/active_admin_import/importer.rb
Expand Up @@ -172,6 +172,7 @@ def detect_csv_options
else
options[:csv_options] || {}
end.reject { |_, value| value.nil? || value == "" }
@csv_options[:col_sep] = model.col_sep if model.respond_to?(:col_sep)
end
end
end
3 changes: 2 additions & 1 deletion lib/active_admin_import/model.rb
Expand Up @@ -65,7 +65,8 @@ def default_attributes
csv_headers: [],
file: nil,
force_encoding: 'UTF-8',
hint: ''
hint: '',
col_sep: ';'
}
end

Expand Down

0 comments on commit ec48635

Please sign in to comment.