# Union of two forms in one

**URL:** <https://www.ruby-forum.com/t/union-of-two-forms-in-one/180991>\
**Category:** Rails\
**Created:** [January 3, 2010, 4:47am UTC](https://www.ruby-forum.com/t/union-of-two-forms-in-one/180991 "2010-01-03T04:47:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nexon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/b5a626/32.png) [@nexon](https://www.ruby-forum.com/u/nexon)\
**Post date:** [January 3, 2010, 4:47am UTC](https://www.ruby-forum.com/t/union-of-two-forms-in-one/180991/1 "2010-01-03T04:47:34Z")

</div>

Hello, I have two forms. One of them is for keep the info in BBDD, and  
the other is to pay in PayPal.

In my store I have in tienda\_controller.rb an action to checkout. It  
redirect you to checkout1.html.erb

#views/tienda/checkout1.html.erb

# PASO 1

\<%= error\_messages\_for ‘pedido’ %\>

\<% form\_for :pedido, :url =\> { :action =\> :save\_order } do |form| %\>  
  
Introduce tus datos de facturaciÃ³n.

```
  <div>
    <%= form.label :nombre, "Nombre:" %>
    <%= form.text_field :nombre, :size => 40 %>
  </div>

  <div>
    <%= form.label :direccion, "DirecciÃ³n:" %>
    <%= form.text_area :direccion, :rows => 3, :cols => 40 %>
  </div>

  <div>
    <%= form.label :email, "E-Mail:" %>
    <%= form.text_field :email, :size => 40 %>
  </div>

  <div>
    <%= form.label :tipo_pago, "Pago con:" %>
    <%=
      form.select :tipo_pago,
                   Pedido::TIPOS_PAGO,
                  :prompt => "Selecciona mÃ©todo de pago"
    %>
  </div>

  <%= submit_tag "Aceptar pedido", :class => "submit" %>
</fieldset>

```

\<% end %\>

Here you will introduce an billing info.

when you finish this form and submit, you will redirect to a page that  
only can push a button “Pay with PayPal”. The form is this:

#views/tienda/checkout.html.erb

\<% form\_tag ‘[https://www.sandbox.paypal.com/cgi-bin/webscr](https://www.sandbox.paypal.com/cgi-bin/webscr)’ do %\>  
\<%= hidden\_field\_tag “cmd”, “\_cart” %\>  
\<%= hidden\_field\_tag “upload”, “1” %\>  
\<%= hidden\_field\_tag “business”, “removed\_email\_address@domain.invalid” %\>  
\<%= hidden\_field\_tag “currency\_code”, value=“EUR” %\>  
\<%= hidden\_field\_tag “country”, value=“ES” %\>  
\<%= hidden\_field\_tag “notify\_url”, “payment\_notifications\_url” %\>

\<%= render(:partial =\> “paypal\_item”, :collection =\> @carrito.items)  
%\>

\<%= hidden\_field\_tag “return”,  
“[http://localhost:3000/tienda/finalizado](http://localhost:3000/tienda/finalizado)” %\>  
\<%= submit\_tag “Comprar en PayPal”, :class =\> “submit” %\>  
\<% end %\>

and my tienda\_controller

def save\_order  
@carrito = encontrar\_carrito  
@pedido = Pedido.new(params[:pedido])  
@pedido.anadir\_item\_lineas\_de\_carrito(@carrito)  
if @pedido.save  
#session[:carrito] = nil  
redirect\_to\_paypal(“Solo queda un ultimo paso. Realiza el pago con  
PayPal: un mÃ©todo mÃ¡s seguro para pagos en internet.”)  
else  
render :action =\> :checkout1  
end  
end

Only I want that when the user want to checkout don’t redirect to two  
different pages. I want that fills the checkout1 form(Name, address,  
email…) and when the user click the submit button, my page redirect  
him directly to paypal page.

It is possible?
