toddiq
Last Updated: February 25, 2016
·
2.115K
· shavit
Ac5c8c4c9580e06cb7dfef8405cbce34

Blank Facebook Canvas With Rails

Facebook Page Tab App Is Blank?

Facebook page and canvas apps with Rails 4, can lead to a blank white page. In Rails 4, the X-Frame-Options are sets by default, and you should override them, to allow iframes in Rails.

class FacebookClubsController < ApplicationController
  layout "facebook_canvas"

  after_filter :allow_iframe

  def index
  end

  private

  def allow_iframe
    response.headers["X-Frame-Options"] = "GOFORIT"
  end
end

https://gist.github.com/shavit/5171168

http://conpanna.net

Say Thanks
Respond

4 Responses
Add your response

6587
1306cb3c1c4be568ca087de48bc0d967

Oh my god, I wanna kiss you now :D I've been banging my head all day with this and I had no clue where to look at. THANK YOU!!!

over 1 year ago ·
6633
Ac5c8c4c9580e06cb7dfef8405cbce34

@mrfoto I'm glad to hear it works for you

over 1 year ago ·
8715

Great tip! I've been having problems with this for a couple of hours and couldn't figure out what was going on. Thank you!

over 1 year ago ·
8846
Orange avatar

Why set an invalid value for it when you can just remove it altogether?

def allow_iframe
  response.headers.except! 'X-Frame-Options'
end
over 1 year ago ·