0

I'm using the Seed Dump gem to dump some seed data to db/seeds.rb. Except, I need to run a one-line task after I dump these three tables.

The way I invoke db:seed:dump is this:

zeus rake db:seed:dump MODELS=Standard,Category,Brand 

So I tried to override this as follows in lib/tasks/database.rake:

namespace :db do namespace :seed do task(:dump_setup => :environment) do Rake::Task["db:seed:dump"].invoke(:models => "Standard,Category,Brand") puts "did it." end end end 

I have also tried:

namespace :db do namespace :seed do task(:dump_setup => :environment) do Rake::Task["db:seed:dump"].invoke(:models => ['Standard','Category','Brand']) puts "did it." end end end 

I just have the "did it" there as a placeholder until I get this working.

That invocation is not working. It's dumping hundreds of megabytes from my database. Dumping everything.

The work I've done above is based on the most popular answers I have found here. Not sure why it's working.

2
  • Oooh I have a gem that I could publish where you can just dump all from anywhere (irb, wherevs) also, it add's method a dump method to all active record objects so that you can just do Model.dump and it dumps to seeds.rb? Would that be something you might be interested in if I published it? Commented Jan 7, 2014 at 21:05
  • That sounds interesting Drew, I think you would have some takers on that. Commented Jan 8, 2014 at 14:12

1 Answer 1

2
zeus rake db:seed:dump MODELS=Standard,Category,Brand 

MODELS is an environment variable. You need to set the environment variable via ENV before invoking the dependent task:

ENV['MODELS'] = 'Standard,Category,Brand` 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.