What does this rake db:seed error mean?

a 夏天 提交于 2019-12-08 08:17:02

问题


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?


回答1:


"Attribute" may be conflicting with something. Try renaming your Attribute model.



来源:https://stackoverflow.com/questions/2792622/what-does-this-rake-dbseed-error-mean

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!