【问题标题】:Rake doesn't know how to build task 'db:migrate'Rake 不知道如何构建任务 'db:migrate'
【发布时间】:2018-07-13 03:49:43
【问题描述】:

我使用 Ruby on Rails 和 Spree 创建了一个应用程序。

将我的 SQlite 数据库更改为 PostgreSQL 后,我需要迁移我的数据库。 但是当我尝试运行 rake db:migrate, rake db:migrate RAILS_ENV=development, bin/rake db:migrate RAILS_ENV=development 时,我得到了同样的错误。

rake aborted!
Don't know how to build task 'db:migrate:up' (see --tasks)
/usr/local/rvm/gems/ruby-2.3.0/gems/rake-12.3.0/exe/rake:27:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `eval'
/usr/local/rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `<main>'
(See full trace by running task with --trace)

当我运行 --trace 时,我得到以下响应

** Invoke default (first_time)
** Invoke spec (first_time)
** Execute spec
/usr/local/rvm/rubies/ruby-2.3.0/bin/ruby -I/usr/local/rvm/gems/ruby-2.3.0/gems/rspec-core-3.7.0/lib:/usr/local/rvm/gems/ruby-2.3.0/gems/rspec-support-3.7.0/lib /usr/local/rvm/gems/ruby-2.3.0/gems/rspec-core-3.7.0/exe/rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rb
Could not load dummy application. Please ensure you have run `bundle exec rake test_app`
** Execute default

你们有谁知道问题的原因是什么,我应该怎么做?

Rakefile

require 'rubygems'
require 'rake'
require 'rake/testtask'
require 'rspec/core/rake_task'
require 'spree/testing_support/common_rake'


RSpec::Core::RakeTask.new

task default: :spec

desc "Generates a dummy app for testing"
task :test_app do
  ENV['LIB_NAME'] = 'spree/frontend'
  Rake::Task['common:test_app'].invoke
end

【问题讨论】:

  • 什么版本的 Rails?还有 rvm?
  • 你的 rakefile 看起来很奇怪。将这些 require File.expand_path('../config/application', __FILE__)YouApp::Application.load_tasks 添加到您的 Rakefile
  • @nattfodd 你能把这个添加为答案吗?

标签: ruby-on-rails rake spree


【解决方案1】:

我加了,

require File.expand_path('../config/application', __FILE__)

YouApp::Application.load_tasks

到我的 rake 文件。

学分转到@nattfodd

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-10-23
    • 2011-07-17
    • 1970-01-01
    • 2012-07-20
    • 1970-01-01
    • 1970-01-01
    • 2012-06-25
    相关资源
    最近更新 更多