Issue with redirect_to


#1

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/" %> ------------------------------

#2

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