Rails: Make this rake task aware that it is in the test environment

后端 未结 2 1390
北恋
北恋 2020-12-31 04:53

I have the following rake task defined in my lib/tasks folder:

namespace :db do
  namespace :test do
    task :prepare => :environment do
            


        
2条回答
  •  臣服心动
    2020-12-31 05:02

    From reading the db:test tasks's source, it looks like they only care about grabbing the test db info from database.yml, but don't care which actual environment they're doing it under.

    You might need to run rake db:test:prepare RAILS_ENV=test to ensure you're under the test environment.

提交回复
热议问题