stephskardal / rails_admin_import

Rails Admin Import functionality
http://www.endpoint.com/
MIT License
160 stars 122 forks source link

trouble configuring to not edit header names #80

Closed hstoebel closed 7 years ago

hstoebel commented 7 years ago

The attributes in the model I am trying to upload to are not lower case underscored. Some examples are.

I tried to configure it so the header name isn't transformed at all (the user must provide the exact attribute name):

RailsAdmin.config do |config|
  config.configure_with(:import) do |config|
    config.header_converter = lambda {|attrib| attrib }
  end

  config.actions do
    all
    import
  end
end

When I try to import I'm told I didn't provide a SiteName, City etc. Am I doing this wrong? And of course there is always a possibility the problem lies somewhere else

monkbroc commented 7 years ago

I think that should do it. I'm not sure what's going on.

I'd start by checking if the lambda is being called. I would use https://github.com/deivid-rodriguez/pry-byebug

config.header_converter = lambda do |header|
  binding.pry
  header
end
hstoebel commented 7 years ago

sorry I forgot to close this. Turns out there was something very strange going on in our model that was causing records to be rejected. Nothing wrong with this code.