私は次のようなモンゴイドモデルとメソッドを持っています:
class Category
include Mongoid::Document
field :name, :type => String
...
def self.custom_find
...
Str = Struct.new(:arg1, :arg2)
array << Str.new(one, two)
...
end
end
次のエラーが発生します:
dynamic constant assignment (SyntaxError)
Str = Struct.new(:arg1, :arg2)
Str = Struct.new(:arg1, :arg2)
config / initializers / category.rbに移動しようとしましたが、次のようになります。
BSON::InvalidDocument in TrendsController#index
Cannot serialize an object of class Category into BSON.
custom_findの問題のあるメソッドを削除することで、他のすべてが正常に機能するようになります。これはに関連していると思い"Struct"
ます。
何か案が ?