如何编写一个rake任务,将捆绑安装然后rake db:migrate然后rake db:seed.
namespace 'install' do 'bundle install' 'rake db:migrate' end
解决方法
这应该工作,但考虑使用Capistrano / Chef进行部署:
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
或者,你可以设置一个shell别名来做
bundle install && bundle exec rake db:migrate && bundle exec rake db:seed