If I may jst take a couple of seconds of your life, and recount a
(sadly) true story;
I started work about 7 years back, at a very large scale bank. I had
been brought in to try and diagnose why there was a slow down in the
current system that they were using. It was a web-based order tracking
system. The chief designer at the time had very little knowledge of
database's, nor what information was going to be stored in the system,
nor infact, how the system would be used on a day to day basis. So. He
did what your doing, or rather, he took it one step further.
He created a 'flex' table. This had three columns inside. The first
was 'tablename', the second was 'column name' and the third was 'value'.
This allowed him to add "columns" to the "table", or even create whole
new "tables" on an 'ad-hoc' basis. That was perhaps okay for the test
sytem, and then after this, he could say 'users should have firstname,
and lastname' etc. However, he left it and let it go into production.
So, when the amount of records hit 200k, and each 'record' had 17
'fields', well, that meant that -one- table had 17 rows, when it should
have only had 1. Now, imagine storing around 40 tables inside this one
Now, if we can relate this to your situation, your definitely going
down that road from what I can see, but, your also eschewing the whole
'validates_' helpers as well as getting rid of the 'R' in RDBMS. How do
you expect to have any 'relational' query perform well agianst a "flex"
table ?. That 'restriction' column also looks -suspiciously- like an
attempt at a constraint, which, is re-inventing the wheel (and not
'well', no offense meant). I would say either use the database
constraints and/or the rails helpers.
This is, at least to my eyes, what you appear to be doing. If
nothing else, if not even for your own sanity, please think of any poor
programmers who come after you. It's true that programmers often think
differently about the same problem, but, this is not the best way to go.
This is not an attack, nor a 'chewing out', but, perhaps a
suggestion to re-think how your using Rails. If this email offends you
in anyway, feel free to ignore these as the mindless ramblings of a
grizzled but optimistic programmer