how to write a rake task to bundle install then rake db:migrate then rake db:seed?
How to write a rake task that will bundle install then rake db:migrate then rake db:seed.
namespace 'install' do
'bundle install'
'rake db:migrat开发者_开发技巧e'
end
This should work but consider using Capistrano/Chef for deployment:
namespace :install do
task :db_reset do
# bundle install - I do not believe attempting this in a rake file
# is recommended as one would need to ensure it is run in your application
# directory and rvm has loaded correct version of ruby/gemsets (.rvmrc required)
Rake::Task['db:migrate'].invoke
end
end
alternatively, you can setup a shell alias to do
bundle install && bundle exec rake db:migrate && bundle exec rake db:seed
精彩评论