Welcome to Working With Rails

 

Discussion Forums

Discuss all things Ruby on Rails with perhaps the web's most vibrant group of Ruby on Rails enthusiasts.
Nested Dynamic Objects?
2 Posts
Nested Dynamic Objects?

I have a model that has lots of instances of a child model (a widget has many parts). Each part has a label and a value.

What I am trying to achieve is when creating a new widget, I get a form listing all the potential parts and a field where I can enter the value. At the moment the list of potential parts is in an array in the Widget model.

How can I best acheive this so that when I load the page I get the built form, and when I re-visit that widget I get a populated version of the form?

Sounds like you need to write a custom Form Builder:

http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html

See section on Custom Form Builders

2 Posts
Login to add your message