Topic: URLs in Facebook canvas application


I'm developing a multi-page Facebook canvas application. In order to verify that the user is logged in to Facebook on each page, I need to check the signed_request parameter that's sent by Facebook. This requires me to have every link in the application point to the Facebook application URL rather than the application's native URL (otherwise I won't receive the parameter).

For example, everywhere I would normally have a link to '/user/edit' it must instead point to ''. To complicate matters, this application will also function outside of Facebook, so I've a condition that tests whether I'm in Facebook and I need to use this to alter the URLs on the fly.

My current solution works, but it's not very elegant as I'm specifying a URL instead of a domain...

class ApplicationController < ActionController::Base
  def default_url_options
    if in_facebook? 
      super.merge({ :host => '' })

Does anyone know whether I can set the base path somehow? Something like this would be neater:

{ :host => '', :base => 'appname' }

Many thanks.

Last edited by steph(an) (2012-12-06 11:47:27)