Forum: Ruby on Rails rails method to get the current url that called the action?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
633ada55ad6d9831e08a6ae23270baf4?d=identicon&s=25 mixplate (Guest)
on 2007-03-21 02:20
hi, i implemented a captcha and basically need to redisplay the page
with the fetched information.

im trying redirect_to :back after the captcha is valid, but i think its
going back in history. so basically i need to find a way to recapture
the url that called the check captcha function.

thoughts?

thanks.
37c7c5f685b0c8ffaa0fd43d66eb7a8d?d=identicon&s=25 mixplate (Guest)
on 2007-03-21 13:59
when i use render :action, i lose the url that i specified in my routes.
hmmm, or maybe i can just create a new route for the check...
8310c5a7c769345114597bcdef111488?d=identicon&s=25 Ben Munat (Guest)
on 2007-03-21 19:29
(Received via mailing list)
This is in a controller right? You should be able to use
request.request_uri...

b
Ec5a599777854c540fd102ef4691fe10?d=identicon&s=25 Rimantas Liubertas (Guest)
on 2007-03-21 19:36
(Received via mailing list)
2007/3/21, mixplate <rails-mailing-list@andreas-s.net>:
<...>
> im trying redirect_to :back after the captcha is valid, but i think its
> going back in history. so basically i need to find a way to recapture
> the url that called the check captcha function.
>
> thoughts?

redirect_to :back should do exactly what you need - it works on
information contained
in http referef header, so it should go back to the page which
originated the request.
From the source:

when :back
  request.env["HTTP_REFERER"] ?
redirect_to(request.env["HTTP_REFERER"]) : raise(RedirectBackError)


Regards,
Rimantas
--
http://rimantas.com/
This topic is locked and can not be replied to.