For some reason the object is getting saved as a fixnum, and I can't
figure out why. Any ideas?
Here's the setup:
class CreateImportObjects < ActiveRecord::Migration
def self.up
create_table :import_objects do |t|
t.string :object, :limit => 512
t.timestamps
end
end
def self.down
drop_table :import_objects
end
end
class ImportObject < ActiveRecord::Base
serialize :object
end
In order to serialize active records I had to do two things:
1) Wrap the object in an array (import_object.object = [fubar])
The problem here, after a save, I was getting a yaml record returned
instead of a de-serialized object. After much poking around I found
this excellent article explaining that somehow custom classes
(including models it seems) were not in scope:
Upon closer review... and a weekend to clear my head...
This approach was just flat wrong. Don't even think of serializing
activeRecords. It causes all sorts of problems, some you will see,
some will be beneath the water line.
I found memcached and after reading about it, it is exactly what I'm
looking for.