【发布时间】:2014-10-17 22:37:49
【问题描述】:
我创建了一个更改其表名的模型,但现在夹具似乎无法找到它。我需要做些什么来告诉灯具使用哪种型号吗?
我使用的是 Rails 2.0.5。
症状是当我运行rake db:fixtures:load时,出现id字段不能为空的错误。
这很奇怪,因为我有另一个模型正在更改其表名,而且它工作正常。
我有两张桌子:customer 和 long_prefix_orders。他们都需要id 字段。
我有两个看起来像这样的模型:
# app/models/customer.rb
class Customer < ActiveRecord::Base
set_table_name :customer
end
# app/models/order.rb
class Order < ActiveRecord::Base
set_table_name :long_prefix_orders
end
我有两个类似这样的装置:
# test/fixtures/customer.yml
one:
name: Bob
# test/fixtures/long_prefix_orders.yml
one:
name: Party Supplies
customer_id: one
客户夹具工作,而订单夹具不工作。将表名称从复数更改为单数是否足够小以使夹具可以找到它,还是我忘记了其他一些配置?
【问题讨论】: