Why won't Rails deserialize my field?
I am using the Classifier:Bayes as part of a model class. I have the class set up to serialize the classifier to the db.
class Foo < ActiveRecord::Base
serialize :classifier
end
The yaml appears in the db just fine after doing some training and saving the object.
But when I query for the class, instance.classifier is a string
@f = Foo.find(params[:id])
@f.classifier.class # is String
I was under th开发者_JAVA百科e impression that Rails / ActiveRecord would magically deserialize my classifier for me. Is there some setting I need to tweak or am I misunderstanding something?
In the past, I've had to add the class name to the method args...
class Foo < ActiveRecord::Base
serialize :classifier, Classifier::Bayes
end
精彩评论