Comments (12)
@glen-mac , please add backtrace of this error, not only message
from active_admin_import.
@Fivell how do you recommend I do that - as the error appears just as a flash banner on the import screen - not usual rails error screen.
Started POST "/admin/blends/do_import" for ::1 at 2016-03-09 21:29:32 +1100
Processing by Admin::BlendsController#do_import as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"pe3+BP+xgt9KxiNhK7WvagpITSDCfQ+XR4zSSmT64Emz8tlpdHxhwM0gMZ+9HvWKmHOZHR+v8SY88VIp9S+Kgw==", "active_admin_import_model"=>{"file"=>#<ActionDispatch::Http::UploadedFile:0x007fe79e394328 @tempfile=#<Tempfile:/var/folders/9g/bv4ryxsd26s3y_ngdvgljt880000gn/T/RackMultipart20160309-89314-1j6v1a2.csv>, @original_filename="iTool_blends copy.csv", @content_type="text/csv", @headers="Content-Disposition: form-data; name=\"active_admin_import_model[file]\"; filename=\"iTool_blends copy.csv\"\r\nContent-Type: text/csv\r\n">}, "commit"=>"Import"}
Admin Load (0.2ms) SELECT "admins".* FROM "admins" WHERE "admins"."id" = $1 ORDER BY "admins"."id" ASC LIMIT 1 [["id", 1]]
SQL (0.3ms) DELETE FROM "blends"
(0.5ms) BEGIN
(0.1ms) ROLLBACK
Error: undefined method `descriptor=' for #<Blend:0x007fe794537e50>
Redirected to http://localhost:3000/admin/blends/import
Completed 302 Found in 38ms (ActiveRecord: 1.1ms)
from active_admin_import.
@glen-mac , pls also attach screen of flash message
from active_admin_import.
this may be reason https://github.com/activeadmin-plugins/active_admin_import/blob/master/lib/active_admin_import/dsl.rb#L82
from active_admin_import.
from active_admin_import.
@glen-mac , looks like out of the box camel-cased attributes are not supported .
from active_admin_import.
@Fivell I see - any idea on an ETA for the fix, or should I just rename my attributes?
from active_admin_import.
@glen-mac , can you try headers_rewrites options ?
headers_rewrites: { :'Descriptor' => :Descriptor ..... and so on },
from active_admin_import.
like here
active_admin_import/spec/import_spec.rb
Line 103 in 87c584e
from active_admin_import.
or it may be sort of
headers_rewrites: { :'descriptor' => :Descriptor ..... and so on },
from active_admin_import.
@glen-mac , update me after your trying please
from active_admin_import.
@Fivell it worked! Thanks so much for your help. The camel case or uppercase must be the issue..
My final (working) solution:
active_admin_import validate: true,
before_import: ->(importer){ Blend.delete_all },
timestamps: true,
template_object: ActiveAdminImport::Model.new(
# force_encoding: :auto,
:csv_headers => ["descriptor","n","pav","pt","k","ss","es","ts","ca","mg","b","co","cu","fe","mn","mo","se","zn","urea","soa","dap","map","zincstar","mapstar","tsp","ssp","mop","sop","bs90","himag","b10","b15","co21","cu25","cuzn","fe25","mg55","mn32","mo13","mo39","se1","zn35","ams","amt","uat","wsoa","guano","agrotain","basis","flufol","orun","sweep"]
),
headers_rewrites: {:'descriptor' => :Descriptor, :'n' => :N, :'pav' => :Pav, :'pt' => :Pt, :'k' => :K, :'ss' => :sS, :'es' => :eS, :'ts' => :tS, :'ca' => :Ca, :'mg' => :Mg, :'b' => :B, :'co' => :Co, :'cu' => :Cu, :'fe' => :Fe, :'mn' => :Mn, :'mo' => :Mo, :'se' => :Se, :'zn' => :Zn, :'urea' => :UREA, :'soa' => :SOA, :'dap' => :DAP, :'map' => :MAP, :'zincstar' => :ZincStar, :'mapstar' => :MAPStar, :'tsp' => :TSP, :'ssp' => :SSP, :'mop' => :MOP, :'sop' => :SOP, :'bs90' => :BS90, :'himag' => :HiMag, :'b10' => :B10, :'b15' => :B15, :'co21' => :Co21, :'cu25' => :Cu25, :'cuzn' => :CuZn, :'fe25' => :Fe25, :'mg55' => :Mg55, :'mn32' => :Mn32, :'mo13' => :Mo13, :'mo39' => :Mo39, :'se1' => :Se1, :'zn35' => :Zn35, :'ams' => :AMS, :'amt' => :AMT, :'uat' => :UAT, :'wsoa' => :wSOA, :'guano' => :GUANO, :'agrotain' => :Agrotain, :'basis' => :Basis, :'flufol' => :Flufol, :'orun' => :Orun, :'sweep' => :Sweep}
Note: I removed the headers from the .csv file and assigned them in the code itself - due to extra work required to process the .csv files.
from active_admin_import.
Related Issues (20)
- Why version lock? HOT 3
- Getting SQL syntax error, as the values in the insert statement is having extra comma at the end. Also 'created_at' value is coming as null. HOT 3
- Add roles after importing users HOT 4
- Errors on the base of an object break active_admin_import HOT 1
- Wrong count in notification after successful import HOT 2
- on the fly by association - not working for a particular column
- need possibility to wrap whole process inside transaction HOT 1
- Proposal: live processing feedback using rails 5 action cables. HOT 1
- Handle a specific error on import HOT 3
- Creating associations without foreign keys
- Deprecation warnings in log
- Send to importer form additional params
- Calling batch_slice_columns multiple times results in unexpected behavior
- Ability to update or create based on id column being present
- Ability to import serialized hash HOT 1
- Ruby 3.0 Support
- ActiveModel::Errors#keys is deprecated and will be removed in Rails 6.2. HOT 2
- Proposal: Array conversion
- Release version 5? HOT 1
- Error if csv file consists empty columns
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from active_admin_import.