Last Updated: February 25, 2016
·
2.408K
· shavit

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

4 Responses
Add your response

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 ·

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

over 1 year ago ·

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 ·

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 ·