# Issue with redirect\_to

**URL:** <https://www.ruby-forum.com/t/issue-with-redirect-to/54708>\
**Category:** Rails\
**Created:** [March 13, 2006, 4:02pm UTC](https://www.ruby-forum.com/t/issue-with-redirect-to/54708 "2006-03-13T16:02:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Susanta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b2d939/32.png) [@Susanta](https://www.ruby-forum.com/u/Susanta)\
**Post date:** [March 13, 2006, 4:02pm UTC](https://www.ruby-forum.com/t/issue-with-redirect-to/54708/1 "2006-03-13T16:02:18Z")

</div>

Hi all:  
I can’t make redirect\_to to unlock the current iframe using {:TARGET =\>  
“\_top”}. It always stays in the current frame. I checked the  
redirect\_to code, it seems the method does not use “target”. here is the  
source code of redirect\_to from ActionController::Base

def redirect\_to(options = {}, _parameters\_for\_method\_reference) #:doc:  
753: case options  
754: when %r{^\w+://._}  
755: raise DoubleRenderError if performed?  
756: logger.info(“Redirected to #{options}”) unless  
logger.nil?  
757: response.redirect(options)  
758: response.redirected\_to = options  
759: @performed\_redirect = true  
760:  
761: when String  
762: redirect\_to(request.protocol + request.host\_with\_port

- options)  
763:  
764: when :back  
765: redirect\_to(request.env[“HTTP\_REFERER”])  
766:  
767: else  
768: if parameters\_for\_method\_reference.empty?  
769: redirect\_to(url\_for(options))  
770: response.redirected\_to = options  
771: else  
772: redirect\_to(url\_for(options,  
\*parameters\_for\_method\_reference))  
773: response.redirected\_to,  
response.redirected\_to\_method\_params = options,  
parameters\_for\_method\_reference  
774: end  
775: end  
776: end

* * *

’ when %r{^\w+://.\*} ’ does not use ‘parameters\_for\_method\_reference’.  
Bug ?  
I also tried to use response directly as follows:  
response.redirect(params[:url]+’ target="\_top"’)  
response.redirected\_to = params[:url]+’ target="\_top"’  
but it didn’t work. Is this a know bug ?

thanks in advance for your reply.  
regards  
Susanta

Here is my sample code:  
controller: BlogController  
--------------------code-----------------------------------  
class BlogController \< ApplicationController  
def index  
end

def otherFrame  
render(:layout =\> false)  
end

def show  
redirect\_to(params[:url], {:TARGET =\> “\_top”})  
end  
end  
\</BlogController.rb \>  
layout: blog  
blog

\<%= @content\_for\_layout %\> ------------------------------- views: index.rhtml --------------------code-----------------------------------

I am in a different frame

----------------------------- views: otherFrame.rhtml --------------------code-----------------------------------

Locked in a frame?

\<%= link\_to 'click me', :action =\> 'show', :url =\>"http://www.rubyonrails.org/" %\> ------------------------------

---

<div class="post-metadata">

**Author:** ![Susanta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b2d939/32.png) [@Susanta](https://www.ruby-forum.com/u/Susanta)\
**Post date:** [March 13, 2006, 4:19pm UTC](https://www.ruby-forum.com/t/issue-with-redirect-to/54708/2 "2006-03-13T16:19:50Z")

</div>

You cannot possibly do that with server-side script. The only way would  
be to genereate javascript that will redirect browser using target =  
\_top

Susanta wrote:

> Hi all:  
> I can’t make redirect\_to to unlock the current iframe using {:TARGET =\>  
> “\_top”}. It always stays in the current frame. I checked the  
> redirect\_to code, it seems the method does not use “target”. here is the  
> source code of redirect\_to from ActionController::Base
