When exporting, there is an selectbox to choose which column separator to be used in the csv file generated.
This is not working and will always take the default option of the csv converter.
in lib/rails_admin/config/actions/index.rb we have:
header, encoding, output = CSVConverter.new(@objects, @schema).to_csv(params[:csv_options].permit!.to_h)
with a params[:csv_options] being for example {encoding_to: "", generator: {col_sep: ";"}}
the method .to_h transforms the keys in strings but the method .to_csv of /lib/rails_admin/support/csv_converter.rb expects to have the option with symbol keys:
def generate_csv_string(options)
generator_options = (options[:generator] || {}).symbolize_keys.delete_if { |_, value| value.blank? }
method = @objects.respond_to?(:find_each) ? :find_each : :each
CSV.generate(generator_options) do |csv|
I use version rails 4.2.5. Having a look at the documentation of http://devdocs.io/rails~4.2/actioncontroller/parameters
the method to_h sends back a Hash while rails rails 5.0 sends back a HashWithIndifferentAccess (http://api.rubyonrails.org/classes/ActionController/Parameters.html#method-i-to_h) so I guess using rails 5 will fix the issue.
I guess the solution that would work on any cas would be to transform the options parameters in
CSVConverter in a HashWithIndifferentAccess.
When exporting, there is an selectbox to choose which column separator to be used in the csv file generated.
This is not working and will always take the default option of the csv converter.
in
lib/rails_admin/config/actions/index.rbwe have:with a
params[:csv_options]being for example{encoding_to: "", generator: {col_sep: ";"}}the method
.to_htransforms the keys in strings but the method.to_csvof/lib/rails_admin/support/csv_converter.rbexpects to have the option with symbol keys:I use version rails 4.2.5. Having a look at the documentation of http://devdocs.io/rails~4.2/actioncontroller/parameters
the method to_h sends back a Hash while rails rails 5.0 sends back a HashWithIndifferentAccess (http://api.rubyonrails.org/classes/ActionController/Parameters.html#method-i-to_h) so I guess using rails 5 will fix the issue.
I guess the solution that would work on any cas would be to transform the
optionsparameters inCSVConverterin aHashWithIndifferentAccess.