I am creating an application where I want to add metadata about table fields from an enterprise system.
I have a table_structure model which retrieves a table definition information like:
table_name
field_name
Field_type
field_length
...
a particular field may exist in multiple tables like:
tableA
fieldX
tableB
fieldX
regardless of table, I want to add attributes to the field so that
fieldX :has_many :attributes
and the attribute model would be
:field
:attribute
:value
I would like to create a single form where I can capture many attributes. I've seen the nested forms railscast and that's close to what I want to do, but I would like to have the form generated dynamically with different input types because the attributes captured may change.
I was thinking of adding this method to the attribute model and somehow iterating through them and generating the form.
def self.attributes_types
{'Business Essential' => {:field_type=>:radio,:values=>[:y,:n,nil],:default_value=>nil}}
{'Owner' => {:field_type=>:text}}
end
Is Nested form the way to go? I am not adding fields, just attributes to fields, so I can pass a params[:field] to new and use that for my new attribute(s). Is there another way to create this form?