# Complex form issue

**URL:** <https://www.ruby-forum.com/t/complex-form-issue/129217>\
**Category:** Rails\
**Created:** [February 15, 2008, 3:16pm UTC](https://www.ruby-forum.com/t/complex-form-issue/129217 "2008-02-15T15:16:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![buddhi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/eb9ed0/32.png) [@buddhi](https://www.ruby-forum.com/u/buddhi)\
**Post date:** [February 15, 2008, 3:16pm UTC](https://www.ruby-forum.com/t/complex-form-issue/129217/1 "2008-02-15T15:16:11Z")

</div>

I’m designing an application that has products and suppliers. Single  
product has\_many suppliers and each supplier has unique supplier code  
for each product.

The form would facilitate something like

1. Select supplier from the list --\> 2. Type the supplier code related  
to supplier in the text field

The supplier codes can be added dynamically.

#Product model  
class Product \< ActiveRecord::Base  
has\_many :supplier\_codes  
has\_many :suppliers, :through =\> :supplier\_codes  
end

#Supplier\_code model  
class SupplierCode \< ActiveRecord::Base  
belongs\_to :product  
belongs\_to :suppliers  
end

#Supplier model  
class Supplier \< ActiveRecord::Base  
has\_many :supplier\_codes  
has\_many :products, :through =\> :supplier\_codes  
end

The supplier\_code table has these columns  
product\_id  
supplier\_id  
code

I’m stuck with developing controller and form. trying out many things  
but no success so far. Any help welcome.
