【问题标题】:Rake aborted: Don't know how to migrate after rails installRake 中止:安装 rails 后不知道如何迁移
【发布时间】:2014-10-01 20:32:53
【问题描述】:

我正在尝试使用新安装的 rails 版本。根据我使用 rails 搭建的模型创建项目并迁移数据库。我遇到了一个不知道如何构建任务 'db::migrate' 错误。

我运行的命令..

移除所有宝石:
for i in 'gem list --no-versions'; do gem uninstall -aIx $i; done

安装rails并创建新项目
sudo gem install rails
rails new test-api
rails generate controller user index
rails generate model user name:string

这就是我的设置..

然后我做了迁移数据库的方法:
rake db::migrate

这是我的输出:

rake db::migrate
rake aborted!
Don't know how to build task 'db::migrate'
/Library/Ruby/Gems/2.0.0/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:241:in `load'
/Library/Ruby/Gems/2.0.0/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:241:in `block in load'
/Library/Ruby/Gems/2.0.0/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:232:in `load_dependency'
/Library/Ruby/Gems/2.0.0/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:241:in `load'
/Library/Ruby/Gems/2.0.0/gems/spring-1.1.3/lib/spring/command_wrapper.rb:40:in `call'
/Library/Ruby/Gems/2.0.0/gems/spring-1.1.3/lib/spring/application.rb:180:in `block in serve'
/Library/Ruby/Gems/2.0.0/gems/spring-1.1.3/lib/spring/application.rb:153:in `fork'
/Library/Ruby/Gems/2.0.0/gems/spring-1.1.3/lib/spring/application.rb:153:in `serve'
/Library/Ruby/Gems/2.0.0/gems/spring-1.1.3/lib/spring/application.rb:128:in `block in run'
/Library/Ruby/Gems/2.0.0/gems/spring-1.1.3/lib/spring/application.rb:122:in `loop'
/Library/Ruby/Gems/2.0.0/gems/spring-1.1.3/lib/spring/application.rb:122:in `run'
/Library/Ruby/Gems/2.0.0/gems/spring-1.1.3/lib/spring/application/boot.rb:18:in `<top (required)>'
-e:1:in `<main>'
(See full trace by running task with --trace)

【问题讨论】:

    标签: ruby-on-rails ruby rubygems rake


    【解决方案1】:

    我找到了解决方案。如果我刚刚在我的服务器上刷新了我的页面,我会发现这个:

    这给了我运行这个命令的答案:

    bin/rake db:migrate RAILS_ENV=development
    

    【讨论】:

      猜你喜欢
      • 2016-05-14
      • 2013-06-28
      • 2011-04-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-08
      相关资源
      最近更新 更多