Giter Club home page Giter Club logo

Comments (12)

Fivell avatar Fivell commented on July 30, 2024

@glen-mac , please add backtrace of this error, not only message

from active_admin_import.

glen-mac avatar glen-mac commented on July 30, 2024

@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.

Fivell avatar Fivell commented on July 30, 2024

@glen-mac , pls also attach screen of flash message

from active_admin_import.

Fivell avatar Fivell commented on July 30, 2024

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.

glen-mac avatar glen-mac commented on July 30, 2024

@Fivell

screen shot 2016-03-09 at 9 35 48 pm

from active_admin_import.

Fivell avatar Fivell commented on July 30, 2024

@glen-mac , looks like out of the box camel-cased attributes are not supported .

from active_admin_import.

glen-mac avatar glen-mac commented on July 30, 2024

@Fivell I see - any idea on an ETA for the fix, or should I just rename my attributes?

from active_admin_import.

Fivell avatar Fivell commented on July 30, 2024

@glen-mac , can you try headers_rewrites options ?

 headers_rewrites: { :'Descriptor' => :Descriptor ..... and so on },

from active_admin_import.

Fivell avatar Fivell commented on July 30, 2024

like here

headers_rewrites: { :'Author Name' => :author_id },

from active_admin_import.

Fivell avatar Fivell commented on July 30, 2024

or it may be sort of

 headers_rewrites: { :'descriptor' => :Descriptor ..... and so on },

from active_admin_import.

Fivell avatar Fivell commented on July 30, 2024

@glen-mac , update me after your trying please

from active_admin_import.

glen-mac avatar glen-mac commented on July 30, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.