By BoLOBOOLNE payday loans

Facebook apps in Rails: Bug in rfacebook-0.6.4 – fbparams not set

Like a number of other developers, I’ve been beating my head against a wall for the last couple of weeks trying to figure out how to set up a facebook app using ruby on rails.  I finally figured out at least one major problem I’ve been running into — the standard library for writing facebook apps in ruby, rfacebook, has a bug in its latest version 0.6.4.

I haven’t figured out exactly what’s wrong yet, but I’ve figured out how to avoid it.  If you’re getting this kind of error message:

You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.length

The error might comes from a stack trace like this:

.../rfacebook-0.6.4/lib/facebook_rails_controller_extensions.rb:37:in `fbparams'
.../rfacebook-0.6.4/lib/facebook_rails_controller_extensions.rb:60:in `fbsession'
.../rfacebook-0.6.4/lib/facebook_rails_controller_extensions.rb:130:in `require_facebook_login'

Astute developers will open up the code and see that fbparams isn’t being properly initialized because of a simple blunder — calling a method on a potentially nil object before trying to initialize it.  But correcting this mistake won’t get your app to run.  There are other problems too.  The way to fix your app is to back down to rfacebook version 0.6.3:

gem uninstall rfacebook
gem install rfacebook -v 0.6.3

And don’t forget to clear your cookies and your session objects

rm tmp/sessions/*

This has certainly helped me.  I hope it helps you.

  1. leodirac says:

    This problem also goes away in the newest releases, 0.7.0 and 0.7.1.

  1. There are no trackbacks for this post yet.