Multiple Forms One Model

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

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

I have a store_controller which currently has a checkout action and a
save_order action.

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.

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 :slight_smile:

Thanks very much for your response.

I'm going to look into doing this.