I am trying to figure out how to add columns to a database table from
within a controller. I have a client who wants to be able to add
their own attributes to a model from within the running application,
so I don't think using migrations is an option.
Basically, I have a Person model which starts off with some basic
attributes (like first_name and last_name), and my client wants to be
able to add new attributes on the fly through the application (like
birthdate or hometown, or anything he can think of). My plan for
implementing this is to use another model (PersonField) to keep track
of each new attribute's name, label, data type, and default value, and
then tie the creation, updating, or destruction of these PersonField
objects to the addition, changing, or removing of columns to the
'people' table in the database.
To restate it in another way, I'm looking for the equivalent to
'add_column' in a migration, but I'd like to call it from a
I have not been able to find a solution to this problem, but I'm
relatively new to Rails (just a few months experience), so I may not
be looking in the right places.
I'd appreciate any help or suggestions anyone can give me. Thanks for