2015-02-07 69 views
0

下面的文檔是我的模型具有字段類型的數組無法創建mongoid與字段類型數組

class User::Log::Presentation 
    include Mongoid::Document 
    include Mongoid::Timestamps 

    field :name, type: String 
    field :fields, type: Array, default: [] 
end 

當我嘗試創建一個文件,它會引發以下錯誤。

TypeError: no implicit conversion of String into Integer 

我完全失去了這一點。找不到任何答案是其他問題。請幫忙。

+0

你能證明你是如何保存的值? – RSB 2015-02-07 18:08:13

+0

p = User :: Log :: Presentation.new; p.fields = [「date」,「log」]會引發此錯誤。 – gak4u 2015-02-07 18:42:25

回答

1

我做了以下更改並開始工作。

field :fields, type: Array, default: [] 

field :columns, type: Array, default: []