This is a perfect area where Ruby can work its magic. Here's an
example of what you could do:
class Element < ActiveRecord::Base
var = variables.find_or_create_by_name(name)
var.value = value
class Variable < ActiveRecord::Base
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.