2010-05-08 159 views
1

我一直試圖解決這個問題幾個小時,但我似乎無法理解發生了什麼事情。這是什麼rake db:種子錯誤是什麼意思?

我正在使用Rails 3測試版,並希望將一些數據種到數據庫。然而,當我試圖通過DB種子一些值:種子,我得到這個錯誤:

rake aborted!

Attribute(#81402440) expected, got Array(#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 

只是爲了澄清,意圖是有屬性對象有一個數據類型(如字符串,數字等)。

雖然數據類型的遷移定義僅僅是:

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 

誰能告訴我什麼,我做錯了什麼?

回答

4

「屬性」可能與某些內容相沖突。嘗試重命名您的Attribute模型。

+0

讓我的一天更燦爛:) – 2010-05-08 05:43:13