Search code examples
ruby-on-railsmigrationseedmina

Rails / Mina Gem Creating Custom task to do seeding


I'm using the mina gem since 2 weeks and I've searched online to find a nice way to do my seeding in my rails staging.

The seed must be a task so it is not called every time a deploy is done.

What I already have is the following:

desc "Seed data to the database"
task :seed do
    queue "bundle exec rake db:seed RAILS_ENV=staging"
end

Do you think this is correct, I know for 100% that it works if I just type the command on the server.

Kind regards.


Solution

  • I first tried using verbose like

    mina seed --verbose
    

    This gave me the error:

    Could not locate gemfile
    

    So he could not reach the gemfile on the server so I had to do the following:

    desc "Seed data to the database"
    task :seed => :environment do
      queue "cd apps/default/current"
      queue "bundle exec rake db:seed RAILS_ENV=staging"
    end