Message from discussion
redirect_to HTTP POST
MIME-Version: 1.0
Message-ID: <858f281b-95e0-41b6-bfe1-ad489332983b@8g2000hse.googlegroups.com>
Date: Wed, 23 Apr 2008 18:53:33 -0700 (PDT)
Received: by 10.100.95.19 with SMTP id s19mr188287anb.17.1209002013902; Wed,
23 Apr 2008 18:53:33 -0700 (PDT)
X-IP: 210.8.37.162
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US;
rv:1.8.0.10) Gecko/20070228 Camino/1.0.4,gzip(gfe),gzip(gfe)
Subject: redirect_to HTTP POST
From: taryn <googleGro...@taryneast.org>
To: Ruby on Rails Oceania <rails-oceania@googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Hey all,
So we're using acts_as_authenticated, and redirecting to the url they
asked for once they log back into a timed-out account.
The problem is that redirect_to doesn't seem to preserve the HTTP
method. This is ok for the faked-up methods eg using "_method=delete"
But if the URL a person asked for was a POST it fails miserably with a
routing error (eg:
no route found to match "/user/42/orders/23/clone" with
{:method=>:get}
These sorts of URLs are usually kept inside a button_to.
if the user, say, has their orders page open for a while, and comes
back after lunch and clicks "clone me order number 23", and s
redirected to the login page, when returning it spews as per above
error message rather than actually redirecting.
I've been trying to hunt around inside the code to find some way of
passing in the http method, but have so far come up blank. I've also
tried passing in the method via the "_method" parameter - but it
doesn't work, even for the delete/put buttons (I have a "delete order"
button, and it redirects to the show page for the order).
Putting some basic printf debugging into store_location shows that the
request method has been accurately populated with post/put/delete...
but I can't find a magic combination to actually pass that into
redirect_to... becuase it only seems to accept a uri (without request
headers).
any ideas?