I'm new to MVC. I'm using Padrino with MongoMapper and Haml to try to create this application.
I have a database of items, each of which has a hash associated with it called 'params'. This hash has some required keys, but mostly arbitrary/random keys. Some of the keys have a finite set of allowable values.
For example:
item.params["password"] does NOT have a finite set of possible values.
item.params["color"] must be one of %w{red blue green}
What's the best way to create an editor for the items in this hash? I'd want a text-field for free-form values and menus for finite values. I'd also like these menus to have "Create New" as the bottom choice, so I can't just hard-code all of the finite-value sets.
The best thing I can come up with for this is to have a new collection(table) in the DB that's just a Hash of default values. If your key isn't in this hash, you get a text-box.
Seems like there has to be a better way though.