Search code examples
ruby-on-railsfacebookapiruby-on-rails-4facebook-canvas

Point me to a Rails 4 example with Facebook canvas


I only find examples of old Rails usage of the Facebook canvas app. Especially with the latest changes Facebook made to the API's.

I am a little bit stuck with that. Does anyone now a gem + example or any other information how to use it properly in Rails 4?


Solution

  • I successfully made it running with Koala gem. It provides you special method for parsing signed requests, so you can easily implement fetching data.

    Koala::Facebook::OAuth.new('someapp','your_secret).parse_signed_request(params[:signed_request])

    Find more info & usage here: https://github.com/arsduo/koala/wiki/OAuth

    You may also need to enable iframe for your controllers which can be done like this:

    class MyController < ApplicationController
      after_filter :allow_iframe
    
      private
    
      def allow_iframe
        response.headers.except! 'X-Frame-Options'
      end
    end