当我发现种子文件有问题时,我正在用 Faker 的几千条记录为开发 postgres 数据库做种。我中止了种子操作并回滚了插入并修复了seeds.rb 文件。
当我再次运行它时,每个rake db:*任务都运行了两次。我可以跑得rake routes很好,但如果我跑了,rake db:drop我会得到这样的结果:
$ rake db:drop
Dropped database 'vp_development'
Dropped database 'vp_development'
Run Code Online (Sandbox Code Playgroud)
如果我尝试运行 migrate ,当它尝试应用索引时,整个事情就会崩溃,因为它已经创建了这些列。
我只有一个默认的 Rakefile,在 lib 或其他任何地方都没有自定义 rake 文件。
如果有任何区别,环境是 rails 5.0.0.1 和 ruby 2.2.2。我现在很迷茫。
这是我的 Rakefile
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require_relative 'config/application'
Rails.application.load_tas
Run Code Online (Sandbox Code Playgroud)
我已经看到其他线程暗示它可能是 gem 的问题,但是在这个问题开始的几天内我没有添加新的 gem。无论如何,这是gemfile。
source 'https://rubygems.org'
# Bundle edge Rails …Run Code Online (Sandbox Code Playgroud)