Forum: Ruby on Rails POSTing to a different website in a controller action

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Scott (Guest)
on 2007-05-28 06:24
(Received via mailing list)
I have a page that has form that I want to submit to one of my
actions. However, inside of the action, I want to post to a different
website and have the browser go to that website.

The code I found on the groups seems to indicate I should do something
like the following. However, when I do the POST, I only see raw html
in the browser. Anyone have a suggestion on how to do this?

Here's the action in my controller:

  def pre_place_order
    parameters =
    parameters['business'] = Variable::paypal_business_account
    parameters['upload'] = "1"
    parameters['cmd'] = "_cart"
    parameters['redirect_cmd'] = "_xclick"
    parameters['return'] = "http://#{Variable::server_hostname}/

    idx = 0
    for item in @cart.shopping_cart_items do
      idx += 1
      parameters['item_name_#{idx}'] =
      parameters['item_number_#{idx}'] =
      parameters['amount_#{idx}'] = item.product.price. to_s

       if item.ship then
        parameters['shipping_#{idx}'] =

    uri = URI.parse(Variable::paypal_transaction_url)
    http =
    headers, res =, parameters)
    render res


Steve R. (Guest)
on 2007-05-28 06:54
(Received via mailing list)

render :text => res

you might also set the content type to text/html...

On May 27, 2007, at 7:23 PM, Scott wrote:

>     for item in @cart.shopping_cart_items do
> >

Steve R.
This topic is locked and can not be replied to.