这个 rake db:seed 错误是什么意思?
我已经尝试解决这个问题几个小时了,但我似乎无法理解发生了什么。
我正在使用 Rails 3 beta,并且想要将一些数据植入数据库。但是,当我尝试通过 db:seed 播种某些值时,出现以下错误:
耙子中止!
预期属性(#81402440),得到数组(#69024170)
seeds.rb 是:
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 等)。
虽然 DataType 的迁移定义仅仅是:
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
任何人都可以告诉我我做错了什么吗?
I've been trying to solve this problem for a couple of hours but I can't seem to understand what's going on.
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:
rake aborted!
Attribute(#81402440) expected, got Array(#69024170)
The seeds.rb is:
DataType.delete_all
DataType.create(
:name => 'String'
)
And I got these classes:
class DataType < ActiveRecord::Base
has_many :attributes
end
class Attribute < ActiveRecord::Base
belongs_to :data_types
end
Just to clarify, the intention is having Attribute objects have one data type (such as String, Number, etc.).
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
“属性”可能与某些东西相冲突。尝试重命名您的
Attribute
模型。"Attribute" may be conflicting with something. Try renaming your
Attribute
model.