问题描述
我已经尝试解决这个问题几个小时了,但我似乎无法理解发生了什么.
I've been trying to solve this problem for a couple of hours but I can't seem to understand what's going on.
我正在使用 Rails 3 测试版,并希望将一些数据植入数据库.但是,当我尝试通过 db:seed 播种一些值时,出现此错误:
I'm using Rails 3 beta, and want to seed some data to the database. However, when I try to seed some values through db:seed, I get this error:
抽水中止!
属性(#81402440)预期,得到数组(#69024170)
Attribute(#81402440) expected, got Array(#69024170)
seeds.rb 是:
The seeds.rb is:
DataType.delete_all
DataType.create(
:name => 'String'
)
我得到了这些课程:
class DataType < ActiveRecord::Base
has_many :attributes
end
class Attribute < ActiveRecord::Base
belongs_to :data_types
end
澄清一下,目的是让 Attribute 对象具有一种数据类型(例如 String、Number 等).
Just to clarify, the intention is having Attribute objects have one data type (such as String, Number, etc.).
虽然 DataType 的迁移定义仅仅是:
While the migration definition for DataType is merely:
class CreateDataTypes < ActiveRecord::Migration
def self.up
create_table :data_types do |t|
t.string :name
t.timestamps
end
end
def self.down
drop_table :data_types
end
end
谁能告诉我我做错了什么?
Can anyone tell me what I'm doing wrong?
推荐答案
属性"可能与某些内容发生冲突.尝试重命名您的 Attribute
模型.
"Attribute" may be conflicting with something. Try renaming your Attribute
model.
这篇关于这个 rake db:seed 错误是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!