Module: Carrot::Facebook::Controller

Extended by:
ActiveSupport::Concern
Defined in:
lib/carrot-facebook/controller.rb

Instance Method Summary collapse

Instance Method Details

#top_redirect_to(*args) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/carrot-facebook/controller.rb', line 8

def top_redirect_to(*args)
  if request.env[:is_iframe_app]
    @redirect_url = [ENV["FACEBOOK_APP_URL"], url_for(*args)].join

    render :layout => false, :inline => %Q{
      <html><head>
        <script type="text/javascript">
          window.top.location.href = #{@redirect_url.to_json};
        </script>
        <noscript>
          <meta http-equiv="refresh" content="0;url=#{@redirect_url}" />
          <meta http-equiv="window-target" content="_top" />
        </noscript>
      </head></html>
    }.html_safe
  else
    redirect_to(*args)
  end
end