Hello
I am trying to create a web app for a clothing store, where the store admin can generate lists of options for different products. For example, the admin can generate an option_list called 'bra sizes' and then attach options to that list.
I have two records:
class OptionList < ActiveRecord::Base
has_and_belongs_to_many :products
has_many :options
end
and:
class Option < ActiveRecord::Base
belongs_to :option_lists
validates_uniqueness_of :name, :scope => :option_list_id
end
I have a form for optionlist, where I want to have a dynamic number of fields for the options, and to create new options with a '+' link that calls a javascript helper to insert_html after the last option field. To do tis, I put the option field in a partial.
I have tried to approach this using fields_for
and accepts_nested_attributes_for
with no luck. Does anyone know the best way to address this? Or is there a post somewhere else that anyone has come accross? Thanks for the help!