db:seed 抛出错误 [英] db:seed is throwing an error

查看:56
本文介绍了db:seed 抛出错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 ruby​​ 1.9.2 和 rails 3.0.9.

I'm using ruby 1.9.2 with rails 3.0.9.

每当我尝试执行 rake db:seed 时,它都会抛出以下错误:

Whenever I try to execute rake db:seed it throws following error:

rake aborted!
uninitialized constant EmployeeCategory

我在 config/application.rb 文件中禁用了线程安全并启用了dependency_loading".

I've disabled threadsafe and enabled 'dependency_loading in config/application.rb file.

config.threadsafe! unless $rails_rake_task
config.dependency_loading = true

但是还是不行.

这是seed.rb文件的内容

Here's the content of seed.rb file

StudentCategory.destroy_all
StudentCategory.create([
 {:name=>"OBC",:is_deleted=>false},
 {:name=>"General",:is_deleted=>false}
])

EmployeeCategory.create([
{:name => 'Management',:prefix => 'MGMT',:status => true},
{:name => 'Teaching',:prefix => 'TCR',:status => true},
{:name => 'Fedena Admin',:prefix => 'Admin',:status => true},
{:name => 'Non-Teaching',:prefix => 'NTCR',:status => true}
])
EmployeePosition.create([
{:name => 'Principal',:employee_category_id => 2,:status => true},
{:name => 'Jr.Teacher',:employee_category_id => 3,:status => true},
{:name => 'Clerk',:employee_category_id => 4,:status => true}
])

推荐答案

这可能是一个显而易见的问题,但是您是否在/models 中创建了您的 employee_category.rb 模型?发现每次出现这个错误时我都会创建视图、控制器和路由,但忘记了一些简单的事情,比如添加模型文件.

This may be an obvious one, but do you have your employee_category.rb model created in /models? Found that every time I get this error I create the view, controller, and route, but forget something simple like adding the model file.

这篇关于db:seed 抛出错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆