title: Authlogic::Session::Activation::NotActivatedError
body: <p>Using authlogic gem to validate user log in in the browser but getting &quot;Your account in not active error&quot; I have tried all the solutions I could find over the web but none of them seem to work.  <br /></p>
  <p>Calling the command <code>Authlogic::Session::Base.controller = Authlogic::ControllerAdapters::RailsAdapter.new(controller)</code> before creating a session solves the problem at least in <code>irb</code>.  <br/></p>
  <p>Doing the same in the <code>UserSessionsController</code> dosent get you anywhere. I have tried calling the <code>before_action :activate_authlogic</code> in the <code>UserSessionsController</code> while the definition for the said function was placed in <code>application_controller.rb</code> <br /></p>
  <p>Here is my code</p>
  <h3>user_sessions_controller.rb</h3>
  <pre><code>class   UserSessionsController &lt; ApplicationController
    def new
      @user_session = UserSession.new
    end
  
    def create
      @user_session = UserSession.new(user_session_params.to_h)
      if @user_session.save
        redirect_to root_url
      else
        render :action =&gt; :new
      end
    end
  
    def destroy
      current_user_session.destroy
      redirect_to new_user_session_url
    end
  
    private
  
    def user_session_params
      params.require(:user_session).permit(:login, :password, :remember_me)
    end
  
  end
  </code></pre>
  <h3>user_session.rb</h3>
  <pre><code>class UserSession &lt; Authlogic::Session::Base
  end
  </code></pre>
  <h3>application_controller.rb</h3>
  <pre><code>class ApplicationController &lt; ActionController::Base
    helper_method :current_user_session, :current_user
  
    private
      def current_user_session
        return @current_user_session if defined?(@current_user_session)
        @current_user_session = UserSession.find
      end
  
      def current_user
        return @current_user if defined?(@current_user)
        @current_user = current_user_session &amp;&amp; current_user_session.user
      end
  
      # def activate_authlogic
      #   Authlogic::Session::Base.controller = Authlogic::ControllerAdapters::RailsAdapter.new(self)
      # end
  end
  </code></pre>
  <h3>user.rb</h3>
  <pre><code>class User &lt; ApplicationRecord
    has_one :user_profile
  
    acts_as_authentic do |c|
      c.crypto_provider = ::Authlogic::CryptoProviders::SCrypt
    end
  
    validates :email,
      format: {
        with: /@/,
        message: &quot;should look like an email address.&quot;
      },
      length: { maximum: 100 },
      uniqueness: {
        case_sensitive: false,
        if: :will_save_change_to_email?
      }
  
    validates :login,
      format: {
        with: /\A[a-z0-9]+\z/,
        message: &quot;should use only letters and numbers.&quot;
      },
      length: { within: 8..100 },
      uniqueness: {
        case_sensitive: false,
        if: :will_save_change_to_login?
      }
  
    validates :password,
      confirmation: { if: :require_password? },
      length: {
        minimum: 8,
        if: :require_password?
      }
    validates_presence_of :password_confirmation
      length: {
        minimum: 8,
        if: :require_password?
    }
  end
  </code></pre>
  <p>and just in case</p>
  <h3>routes.rb</h3>
  <pre><code>Rails.application.routes.draw do
    # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
    root &quot;home_page#index&quot;
    get &quot;/home&quot;, to: &quot;home_page#index&quot;
  
    resources :users do
      resource :user_profile
    end
  
    resource :user_session
  end
  </code></pre>
  <p>i did think it was a bug so i updated the authlogic gem to <strong>6.4.1</strong> from <strong>6.4.0</strong>.  Needless to say it didn't help either.</p>
  <p>and here is</p>
  <h3>Gemfile</h3>
  <pre><code>source 'https://rubygems.org'
  git_source(:github) { |repo| &quot;https://github.com/#{repo}.git&quot; }
  
  ruby '2.7.2'
  
  # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
  gem 'rails', '~&gt; 6.1.1'
  # Use postgresql as the database for Active Record
  gem 'pg', '~&gt; 1.1'
  # Use Puma as the app server
  gem 'puma', '~&gt; 5.0'
  # Use SCSS for stylesheets
  gem 'sass-rails', '&gt;= 6'
  # Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
  gem 'webpacker', '~&gt; 5.0'
  # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
  gem 'turbolinks', '~&gt; 5'
  # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
  gem 'jbuilder', '~&gt; 2.7'
  # Use Redis adapter to run Action Cable in production
  # gem 'redis', '~&gt; 4.0'
  # Use Active Model has_secure_password
  # gem 'bcrypt', '~&gt; 3.1.7'
  gem 'authlogic'
  
  # Use Active Storage variant
  # gem 'image_processing', '~&gt; 1.2'
  
  # Reduces boot times through caching; required in config/boot.rb
  gem 'bootsnap', '&gt;= 1.4.4', require: false
  
  gem &quot;scrypt&quot;, &quot;~&gt; 3.0&quot;
  
  group :development, :test do
    # Call 'byebug' anywhere in the code to stop execution and get a debugger console
    gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
  end
  
  group :development do
    # Access an interactive console on exception pages or by calling 'console' anywhere in the code.
    gem 'web-console', '&gt;= 4.1.0'
    # Display performance information such as SQL time and flame graphs for each request in your browser.
    # Can be configured to work on production as well see: https://github.com/MiniProfiler/rack-mini-profiler/blob/master/README.md
    gem 'rack-mini-profiler', '~&gt; 2.0'
  
    gem 'rspec-rails', '~&gt; 4.0.2'
  
    gem 'capybara'
  end
  
  # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
  gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
  </code></pre>
  <h3>new.html.erb (form)</h3>
  <pre><code>&lt;%= form_for @user_session, url: user_session_url do |f| %&gt;
    &lt;% if @user_session.errors.any? %&gt;
    &lt;div id=&quot;error_explanation&quot;&gt;
      &lt;h2&gt;&lt;%= pluralize(@user_session.errors.count, &quot;error&quot;) %&gt; prohibited:&lt;/h2&gt;
      &lt;ul&gt;
        &lt;% @user_session.errors.full_messages.each do |msg| %&gt;
          &lt;li&gt;&lt;%= msg %&gt;&lt;/li&gt;
        &lt;% end %&gt;
      &lt;/ul&gt;
    &lt;/div&gt;
    &lt;% end %&gt;
    &lt;%= f.label :login %&gt;&lt;br /&gt;
    &lt;%= f.text_field :login %&gt;&lt;br /&gt;
    &lt;br /&gt;
    &lt;%= f.label :password %&gt;&lt;br /&gt;
    &lt;%= f.password_field :password %&gt;&lt;br /&gt;
    &lt;br /&gt;
    &lt;%= f.label :remember_me %&gt;&lt;br /&gt;
    &lt;%= f.check_box :remember_me %&gt;&lt;br /&gt;
    &lt;br /&gt;
    &lt;%= f.submit &quot;Login&quot; %&gt;
  &lt;% end %&gt;
  </code></pre>
  <h3>migration table</h3>
  <pre><code>class CreateUsers &lt; ActiveRecord::Migration[6.1]
    def change
      create_table :users do |t|
        # Authlogic::ActsAsAuthentic::Email
        t.string    :email
        t.index     :email, unique: true
  
        # Authlogic::ActsAsAuthentic::Login
        t.string    :login
  
        # Authlogic::ActsAsAuthentic::Password
        t.string    :crypted_password
        t.string    :password_salt
  
        # Authlogic::ActsAsAuthentic::PersistenceToken
        t.string    :persistence_token
        t.index     :persistence_token, unique: true
  
        # Authlogic::ActsAsAuthentic::SingleAccessToken
        t.string    :single_access_token
        t.index     :single_access_token, unique: true
  
        # Authlogic::ActsAsAuthentic::PerishableToken
        t.string    :perishable_token
        t.index     :perishable_token, unique: true
  
        # See &quot;Magic Columns&quot; in Authlogic::Session::Base
        t.integer   :login_count, default: 0, null: false
        t.integer   :failed_login_count, default: 0, null: false
        t.datetime  :last_request_at
        t.datetime  :current_login_at
        t.datetime  :last_login_at
        t.string    :current_login_ip
        t.string    :last_login_ip
  
        # See &quot;Magic States&quot; in Authlogic::Session::Base
        t.boolean   :active, default: false
        t.boolean   :approved, default: false
        t.boolean   :confirmed, default: false
  
        t.timestamps
      end
    end
  end
  </code></pre>