当我尝试播放我的Rails 4.0应用程序时,我收到此错误:
$ rake db:seed --trace
** Invoke db:seed (first_time)
** Invoke db:seed:common (first_time)
rake aborted!
Don't know how to build task 'db:seed:original'
/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task_manager.rb:62:in `[]'
/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task.rb:57:in `lookup_prerequisite'
/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task.rb:53:in `block in prerequisite_tasks'
/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task.rb:53:in `map'
/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task.rb:53:in `prerequisite_tasks'
/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task.rb:199:in `invoke_prerequisites'
/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task.rb:178:in `block in invoke_with_call_chain'
/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task.rb:201:in `block in invoke_prerequisites'
/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task.rb:199:in `each'
/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task.rb:199:in `invoke_prerequisites'
/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task.rb:178:in `block in invoke_with_call_chain'
/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/application.rb:150:in `invoke_task'
/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/application.rb:106:in `block (2 levels) in top_level'
/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/application.rb:106:in `each'
/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/application.rb:106:in `block in top_level'
/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/application.rb:115:in `run_with_threads'
/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/application.rb:100:in `top_level'
/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/application.rb:78:in `block in run'
/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/opt/rbenv/versions/2.2.0/lib/ruby/2.2.0/rake/application.rb:75:in `run'
/opt/rbenv/versions/2.2.0/bin/rake:33:in `<main>'
Tasks: TOP => db:seed => db:seed:common
但我找不到任何名为original
的种子任务的引用。这是内置于Rails的内容吗?
如果我通过例如手动调用任何种子任务rake db:seed:whatever
,它运作正常。
有趣的是,在我的种子文件夹中创建一个名为original.seeds.rb
的空文件后,播种运行没有错误。
导致此错误的原因是什么?
答案 0 :(得分:2)
您需要创建一个虚拟db/seeds.rb
来解决此问题。当你运行rake db:seed
时,它希望你有这个文件。