views:

353

answers:

1

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 the impression that Rails / ActiveRecord would magically deserialize my classifier for me. Is there some setting I need to tweak or am I misunderstanding something?

+2  A: 

In the past, I've had to add the class name to the method args...

class Foo < ActiveRecord::Base
  serialize :classifier, Classifier::Bayes
end
Ben