storing a hash in the data base


This is a perfect area where Ruby can work its magic. Here's an
example of what you could do:

class Element < ActiveRecord::Base
   has_many :variables

   def [](name)

   def []=(name,value)
     var = variables.find_or_create_by_name(name)
     var.value = value

class Variable < ActiveRecord::Base
   belongs_to :element

Now you will be able to do the following:

e = Element.create
e["x"] = 800
e["y"] = 600
e["whatever"] = "anything"

e["x"] #-> "800"
e["y"] #-> "600"
e["whatever"] #-> "anything"

Isn't that fantastic? Note that this is assuming that your value field
is a TEXT which will return anything as a string. You could also store
a type and coerce the values, let me know if you want more detail.

Michael Bleigh