我试图从新安装的rails版本开始。创建项目并根据我使用rails搭建的模型迁移数据库。而且我遇到了一个不知道如何构建任务&db; 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)
答案 0 :(得分:0)
我找到了解决方案。如果我只是在我的服务器上刷新我的页面,我会发现这个:
这给了我运行这个命令的答案:
bin/rake db:migrate RAILS_ENV=development