我做错了什么?我有这个基于Mongoid的模型:
class ReadableThing
include Mongoid::Document
field :shop, type: Integer
field :user, type: Integer
field :title, type: String
field :s_title, type: String
field :s_desc, type: String
field :is_part, type: Boolean
field :pieces, type: Array
def self.with_shop_only(shop, with_parts)
ReadableThing.where(shop_id: shop, user: nil, is_part: with_parts)
end
def self.with_shop_and_user(shop, user_id, with_parts)
ReadableThing.where(brokerage_shop_id: shop, user: user_id, is_part: with_parts)
end
end
并且在运行此代码时:
ReadableThing.create({
shop: 2,
user: nil,
title: "Ooohh samples",
s_title: "SPL",
s_desc: nil,
is_part: true,
pieces: ["this","is","a","sample"],
})
我收到此错误:
TypeError: no implicit conversion of String into Integer
我已经能够将这些东西追踪到“碎片”阵列,没有它,一切都很完美。但是,我无法弄清楚我做错了什么。
任何人都可以帮我一把吗?