# multiple fields\_for, same model

**URL:** <https://discuss.rubyonrails.org/t/multiple-fields-for-same-model/30873>\
**Category:** rubyonrails-talk\
**Created:** [June 20, 2008, 4:36pm UTC](https://discuss.rubyonrails.org/t/multiple-fields-for-same-model/30873 "2008-06-20T16:36:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nik\_B](https://avatars.discourse-cdn.com/v4/letter/n/ee59a6/32.png) [@Nik\_B](https://discuss.rubyonrails.org/u/Nik_B)\
**Post date:** [June 20, 2008, 4:36pm UTC](https://discuss.rubyonrails.org/t/multiple-fields-for-same-model/30873/1 "2008-06-20T16:36:32Z")

</div>

I have three fields\_for inside a form\_tag.

[http://pastie.org/218918](http://pastie.org/218918)

Two of them, correspond to the same model, :customer, (the two objects, billing\_customer and shipping\_customer have been built in the controller method). When I submit the form, the parameters only include one of the two fields\_for methods and it comes through as the model name, not the object name:

"customer"=\>{...}

I know there is a way to use two fields\_for sections that correspond to the same model... what am I doing wrong here?

-Nik

---

<div class="post-metadata">

**Author:** ![Ajit](https://avatars.discourse-cdn.com/v4/letter/a/a3d4f5/32.png) [@Ajit](https://discuss.rubyonrails.org/u/Ajit)\
**Post date:** [June 20, 2008, 5:40pm UTC](https://discuss.rubyonrails.org/t/multiple-fields-for-same-model/30873/2 "2008-06-20T17:40:25Z")

</div>

Nik can you update mentioned URL with field names as well

try using following: \<% fields\_for :shipping\_customer do |sc| %\> &nbsp;&nbsp;\<%= sc.text\_field%\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<% end %\>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<% fields\_for :billing do |bi| %\> &nbsp;&nbsp;...\<%= b.text\_field%\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<% end %\> \<!-- end billing\_fields --\>

&nbsp;&nbsp;\<% fields\_for :billing\_customer do |bc| %\> &nbsp;&nbsp;....\<%= bc.text\_field%\> &nbsp;&nbsp;\<% end %\>

MOdel:

ShippingCustomer.new(params[:shipping\_customer]) Billing.new(params[:billing) ShippingCustomer.new(params[:billing\_customer)

I am using something like this and it is working for me.

let me know

Ajit

---

<div class="post-metadata">

**Author:** ![Nik\_B](https://avatars.discourse-cdn.com/v4/letter/n/ee59a6/32.png) [@Nik\_B](https://discuss.rubyonrails.org/u/Nik_B)\
**Post date:** [June 20, 2008, 5:49pm UTC](https://discuss.rubyonrails.org/t/multiple-fields-for-same-model/30873/3 "2008-06-20T17:49:43Z")

</div>

Just what I needed. Many thanks, Ajit.
