rails server can't start with authlogic #158

Open
snufu opened this Issue Jul 23, 2010 · 1 comment

Projects

None yet

2 participants

@snufu
snufu commented Jul 23, 2010

Hi,
I'm using rails 2.3.5 with authlogic 2.1.5. After requiring authlogic in my environment.rb I get this error message:

/usr/lib/ruby/gems/1.8/gems/authlogic-2.1.5/lib/authlogic/session/callbacks.rb:69:in `send': undefined method `metaclass' for Authlogic::Session::Base:Class (NoMethodError)

The critical piece of code is this:

# If Rails 3, support the new callback syntax                                                                          
if base.send(base.respond_to?(:singleton_class) ? :singleton_class : :metaclass).method_defined?(:set_callback)
  METHODS.each do |method|
    base.class_eval <<-"end_eval", __FILE__, __LINE__
      def self.#{method}(*methods, &block)                                                                             
        set_callback :#{method}, *methods,&block                                                                      
      end                                                                                                              
    end_eval
   end
 end
end

After commenting it out, it works.

@suung
suung commented Jul 23, 2010

i would suggest this

monkeypatch to keep singleton behaviour backwards compatible

class Object
def metaclass
class << self
self
end
end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment