I’m writing an application that stores models attributes in a single
column called data, using Marshal. My ultimate goal is to allow any/
all records to be saved in one database table. I’m wondering if
there’s a better way to do this, and also if I should Base64 encode
the result of Marshal.dump as mentioned here: http://www.ruby-forum.com/topic/164786#723805
I’m writing an application that stores models attributes in a single
column called data, using Marshal. My ultimate goal is to allow any/
all records to be saved in one database table. I’m wondering if
there’s a better way to do this, and also if I should Base64 encode
the result of Marshal.dump as mentioned here:How to save Ruby object as a blob in MySQL - Ruby - Ruby-Forum
This design is well on it’s way to ending up on TheDailyWTF. Several
things:
using Marshal is a bad, bad, bad idea. The format is fragile when
class definitions are changed and not guaranteed to be readable across
Ruby versions. It’s also completely incomprehensible to anything
besides Ruby.
you’re re-implementing the idea of serialized fields (check the
ActiveRecord docs) using Marshal instead of YAML.
you’re trying to jam all the data into one table. This is almost
certainly wrong.
If your data set is REALLY as unstructured as you’re implying, you may
want to look at some of the schemaless document DB stuff (CouchDB and
friends).
–Matt J.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.