Rails3 beta3 Authlogic metaclass error

I noticed this problem when I tried to use authlogic today:
undefined method `metaclass' for Authlogic::Session::Base:Class (NoMethodError)

Turns out the fix is pretty simple bpauly posted a comment on http://railsplugins.org with the following:

metaclass has been deprecated in favor of singleton_class. http://github.com/rails/rails/commit/763f32ab47b96289a4d7b7107411a83164bf69de

The following changes should get you running for now.

callbacks.rb line 69:
if base.metaclass.method_defined?(:set_callback)
if base.singleton_class.method_defined?(:set_callback)

password.rb line 185:
if klass.metaclass.method_defined?(:set_callback)
if klass.singleton_class.method_defined?(:set_callback)

So you don’t have to mess much, I took the liberty of forking github and putting the changes in my rails3 branch, so add this to GemFile to fix:

gem ‘authlogic’, :git => ‘git://github.com/danhawkins/authlogic.git’, :branch => ‘rails3”

About Danny

Primarily a Ruby On Rails developer, but I can do other cool stuff too.
This entry was posted in Development, Patches, Ruby / Rails and tagged , , . Bookmark the permalink.

5 Responses to Rails3 beta3 Authlogic metaclass error

  1. Dirk says:

    Very helpful, much easier than sifting through bundled gems. Thanks!

  2. Sam says:

    Would this fix cause a rails 2.3.5 app to break?

  3. admin says:

    I haven’t tested it, but most likely. Can I ask why you would run the rails3 branch on a rails 2.3.5 app in the first place?

  4. Sam says:

    No, I wasn’t thinking of doing that. I was just thinking that if it didn’t break a rails 2.3.5, we could submit it to binarylogic as a patch.

  5. Danny says:

    Ahhh, yeah I see where you are going. Well as far as I know singleton_class will actually work in earlier rails thinking about it. So it should actually work. But… there is a repo at http://github.com/odorcicd/authlogic which has more fixes than my fork. I found it after I had made my fork. We need to ask for that one to be pulled!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>