1

I have to load data into a Spree application. Spree makes use of Rails Engines.

All examples use pretty print or CSV destinations, but I want to use spree models in the destination, eg. SpreeModel.create!(row)

I tried to do rails runner "exec('kiba db/etl/convert-csv.etl')", but I get this error:

db/etl/convert-csv.etl:4:in `parse': uninitialized constant Kiba::Context::Spree (NameError)

I've also tried within the Rails console, without success.

mardocp
  • 13
  • 3
  • As the error indicates, did you initialize Kiba? I.e: Did you install the gem, and required it in your code – Waclock Sep 25 '15 at 21:23

1 Answers1

4

author of Kiba here. Thanks for using it :-)

Since this really looks like a potentially frequently asked question, I wrote a complete blog post providing you 2 possible answers:

How to run Kiba in a Rails environment

Let me know if indeed this works for you!

Thibaut Barrère
  • 8,845
  • 2
  • 22
  • 27
  • Thank you for the well documented answers in your blog post. If I had read before, it would saved me several hours finding the solution in [Kiba :: Cli](https://github.com/thbar/kiba/blob/master/lib/kiba/cli.rb). Nevertheless it has served me to learn some Rake, good lack made me ;-) Great job! Keep it up. – mardocp Sep 27 '15 at 13:42
  • Sorry you spent hours on this, really! Next time please do not hesitate to create a question on SO (always tagged with kiba-etl so I get notified properly!) if you are facing a blocking issue. The programmatic call is a bit buried [in the readme](https://github.com/thbar/kiba#how-do-you-run-your-etl-jobs), and anyway you would have missed the "environment" trick. I'm thankful you posted this question, so this is now properly documented, and helping others! – Thibaut Barrère Sep 28 '15 at 15:38
  • I am having the same issue with this error /Users/rbennacer/projects/kaboom/mop2/config/environments/development.rb:1:in `': uninitialized constant Rails (NameError) – fenec Aug 29 '16 at 14:35
  • Fenec: did you follow what is described in the blog post, in particular the require on environment? If yes, then maybe you need some sort of require 'bundler' to make sure Rails is loaded. – Thibaut Barrère Sep 12 '16 at 16:00