Posted
13 November 2009 @ 10am

Tagged
, , , , ,

Share and Enjoy
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • LinkedIn
  • Digg
  • Twitter
  • Reddit
  • MySpace
  • Technorati
  • StumbleUpon
  • Tumblr
  • Slashdot
  • email
  • Print

authlogic plugin error/fix

I’ve seen this error lots and lots of times dealing with authlogic plugins:

rake aborted!
undefined method `add_acts_as_authentic_module' for ActiveRecord::Base:Class

And I’ve searched on the web for answers and there’s not a really good source as to why it happens or what can be done to fix it.  Yesterday, I put an end to the error in authlogic_facebook_connect (great plugin, BTW) and wanted to post here so the next schlub who comes along googling for a solution will find it.

The conversational explanation is that if you’re attempting to use rake to install, build, unpack or otherwise effect gems, its possible you’ll have issues with the plugins that depend on those not-yet-working gems.  The exact use-case for me is that I have authlogic installed as a gem on my local box.  I have authlogic_facebook_connect installed as a plugin.  I setup capistrano to install the gems on every update of the code to the server (to pickup new gem dependencies in environment.rb).  When the code is deployed to the server and the rake gems:install task is run, authlogic_facebook_connect would cause an error because of its dependence on the yet-to-be-installed authlogic, preventing the installation of authlogic.  The fix is to simply guard the integration code with a check to make sure authlogic is installed.  That way, there will be no errors while installing authlogic and when the server is started immediately after the gems:install, authlogic_facebook_connect will integrate correctly (upon writing this, perhaps a warning would be in order instead of silent ignorance).

The code:

if ActiveRecord::Base.respond_to?(:add_acts_as_authentic_module)
  ActiveRecord::Base.send(:include, AuthlogicFacebookConnect::ActsAsAuthentic)
  Authlogic::Session::Base.send(:include, AuthlogicFacebookConnect::Session)
  ActionController::Base.helper AuthlogicFacebookConnect::Helper
end

I imagine the exact same fix would work for all the various authlogic plugins.

Thanks goes out to the developers of authlogic, authlogic_facebook_connect, and all the other authlogic plugin developers.  You guys have built a really great-to-use, modular, extendable authentication system that I enjoy very much.


blog comments powered by Disqus
prototype-based image preloader