rFacebook and redirect_to

October 23rd, 2007 by Justin Ball

I have been working with rFacebook to try to get a Facebook application up and running. Right now we are trying to integrate our conference application - 51weeks.com with Facebook so that our users can take advantage of existing social networks instead of having to create yet another network at he conference they are attending.

In working on the application I kept getting an exception related to redirect_to:
wrong number of arguments (2 for 1)

The stack trace points to this file:
controller_extensions.rb:463:in `url_for__ALIASED'

So I did what any good developer would do I went to Google and came up with this post.

The poster replaced this line in the gem:
path = url_for__ALIASED(options, *parameters)

with this:
path = options

I am not brave enough to mess around with the gem - it makes deployment a bit of a headache so I sat back and thought about this for a bit. This always helps me. I checked my facebook.yml file. I have been using '/' as the callback_path. I switched that to 'http://www.myserver.com/facebook/'. Then I set the callback path inside of Facebook to 'http://www.myserver.com/facebook/'. I made sure my canvas page url was setup correctly - 'indulgences' in my case.

Next I ran the application inside of Facebook. Like magic everything worked. Now even if I change my facebook.yml file back to '/' everything still seems to work. Morale of the story is to check your configuration when building a Facebook application. Everything has to be just right and it is easy to forget to setup any one of a number of configuration items which can cause you a lot of pain.

Tags:   · · 2 Comments

Leave A Comment

2 responses so far ↓

  • 1 Chris Bucchere Nov 19, 2007 at 11:48 pm

    Thanks, that was incredibly helpful. I was wondering why redirect_to was failing miserably — I had my callback_path set to a relative URL. I absolute-ized the URL and life is good again. Kudos!

  • 2 Robert Spychala Dec 10, 2007 at 12:47 pm

    you can also add:

    def url_for(options = nil, *parameters)
    super options
    end

    to your controller