# Multiple Forms One Model

**URL:** <https://www.ruby-forum.com/t/multiple-forms-one-model/149955>\
**Category:** Rails\
**Created:** [October 1, 2008, 3:35pm UTC](https://www.ruby-forum.com/t/multiple-forms-one-model/149955 "2008-10-01T15:35:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![soderic](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8baadc/32.png) [@soderic](https://www.ruby-forum.com/u/soderic)\
**Post date:** [October 1, 2008, 3:35pm UTC](https://www.ruby-forum.com/t/multiple-forms-one-model/149955/1 "2008-10-01T15:35:49Z")

</div>

I have the following scenario and am trying to find the best way to  
accomplish it.

Model:  
I have an Order model which accepts a customers billing & shipping  
address, order info and order item details.

Controller:  
I have a store\_controller which currently has a checkout action and a  
save\_order action.

View:

1. I have one template / page (checkout.html.erb) with a form for the  
customer to enter their billing and shipping info.
2. I need another template / page which based on the customers country  
selection in the previous page displays the correct currency and  
calculates the correct VAT or Tax info. This will update and display  
the cart totals. The customer will also on this page enter in their  
credit card info and submit for order processing.

Here’s where I have the question.

As you can see I need to break up my checkout page into two pages.  
One for billing and shipping info, and one for the final checkout  
confirmation and the customer to enter their credit card info. After  
the credit card is authorized this would all get submitted to the  
Order model for validation and saving.

I have done this plenty of times in the past but not in Rails and  
wanted to try and find a “rails way” to solve this.

How would you tackle this problem?

Thanks very much.

---

<div class="post-metadata">

**Author:** ![soderic](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8baadc/32.png) [@soderic](https://www.ruby-forum.com/u/soderic)\
**Post date:** [October 1, 2008, 5:20pm UTC](https://www.ruby-forum.com/t/multiple-forms-one-model/149955/2 "2008-10-01T17:20:33Z")

</div>

I would have an orderaddress object that you can split to shipping and  
billing address that belongs to your order model, like this:

belongs\_to :billing\_address, :class\_name =\> ‘OrderAddress’,  
:foreign\_key =\> ‘billing\_address\_id’,  
:dependent =\> :destroy  
belongs\_to :shipping\_address, :class\_name =\> ‘OrderAddress’,  
:foreign\_key =\> ‘shipping\_address\_id’,  
:dependent =\> :destroy

Validate and save this information before going to the cc page. And  
most likely you do not want to save the creditcard info anyways so it  
will be virtual attributes that you validate within the order model.

Thats some information that might help… I’m kinda in the middle of  
spliting my own page so the next step someone else can answer 🙂
