Module: Authlogic::ControllerAdapters::RailsAdapter::RailsImplementation

Defined in:
lib/authlogic/controller_adapters/rails_adapter.rb

Overview

Lets Authlogic know about the controller object via a before filter, AKA “activates” authlogic.

Class Method Summary collapse

Class Method Details

.included(klass) ⇒ Object

:nodoc:



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/authlogic/controller_adapters/rails_adapter.rb', line 32

def self.included(klass) # :nodoc:
  if defined?(::ApplicationController)
    raise AuthlogicLoadedTooLateError.new(
      <<-EOS.strip_heredoc
        Authlogic is trying to add a callback to ActionController::Base
        but ApplicationController has already been loaded, so the
        callback won't be copied into your application. Generally this
        is due to another gem or plugin requiring your
        ApplicationController prematurely, such as the
        resource_controller plugin. Please require Authlogic first,
        before these other gems / plugins.
      EOS
    )
  end

  # In Rails 4.0.2, the *_filter methods were renamed to *_action.
  if klass.respond_to? :prepend_before_action
    klass.prepend_before_action :activate_authlogic
  else
    klass.prepend_before_filter :activate_authlogic
  end
end