Issue Details (XML | Word | Printable)

Key: CODEBASE-134
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Jamie Orchard-Hays
Reporter: Jason Ronallo
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Blacklight Plugin

Authlogic error

Created: 01/Jun/09 04:01 PM   Updated: 25/Sep/09 12:41 PM
Component/s: None
Affects Version/s: None
Fix Version/s: 2.4


 Description  « Hide
I get this error with latest out of trunk:

Authlogic::Session::Activation::NotActivatedError in Catalog#index

Showing vendor/plugins/blacklight/app/views/catalog/_bookmark_control.html.erb where line #1 raised:

You must activate the Authlogic::Session::Base.controller with a controller object before creating objects

Extracted source (around line #1):

1: <% if current_user and current_user.document_is_bookmarked? document[:id] %>
2: <span>This item is in your <%= link_to 'bookmarks', bookmarks_path %></span>
3: <% elsif current_user %>
4: <%- @bookmark ||= Bookmark.new -%>

Trace of template inclusion: vendor/plugins/blacklight/app/views/catalog/_document_list.html.erb, vendor/plugins/blacklight/app/views/catalog/index.html.erb

=====================================

I've monkey patched my copy to comment out the following in the plugin's application_controller.rb:
 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 && current_user_session.user
    end

When application_controller.rb from the plugin is copied to the rails application level leaving @current_user uncommented works. For some reason it only fails for the version inside the plugin.

I should also say that it works uncommented on one machine but not on another. The machine where it is not working is running Ruby Enterprise Edition.

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Jason Ronallo added a comment - 02/Jun/09 08:49 AM
Placing
before_filter :activate_authlogic
In my controllers seems to have solved this issue from cropping up occasionally.

http://www.themomorohoax.com/2009/02/23/authlogic-session-notactivated-you-must-activate-the-authlogic-session-base-controller-with-a-controller-object-before-creating-objects

Jamie Orchard-Hays added a comment - 02/Jun/09 09:36 AM
Jason, do you have config.gem "authlogic" in your environments file?

Jason Ronallo added a comment - 02/Jun/09 01:57 PM
Yes, I do.

I even installed the authlogic gem on the server since I was getting some gem dependency errors as well.

Which controllers rely on authlogic? I've added it to ApplicationController and CatalogController (since I've had to override those anyway). Others that will need the before_filter?

Jamie Orchard-Hays added a comment - 02/Jun/09 04:11 PM
There's some larger issue than using the activate command in the controllers. I don't believe you should need to call activate. The demo app is running fine without calling activate. Something's not configured correctly somewhere as Authlogic mixes into the controllers.

Jason Ronallo added a comment - 03/Jun/09 11:46 AM
Even though it is working in the demo app is it known to be working with a fresh rails and installation of the blacklight plugin?

Jamie Orchard-Hays added a comment - 03/Jun/09 02:00 PM
Jason, I'm in the middle of installing BL in a fresh rails application for the first time. I'd say the instructions are wrong in several places and we need some serious work on this, so I'm going to get on it ASAP.

Anyway, once I got things up and running, I had no load issues. No errors with the controllers, etc. Did you remove application_controller.rb from the main rails app?

Also, do you have

  require File.join(File.dirname(__FILE__), '../vendor/plugins/engines/boot')

above the initializer and

  config.gem 'authlogic'
  config.plugin_paths += ["#{RAILS_ROOT}/vendor/plugins/blacklight/vendor/plugins"]
  config.plugins = %W(engines blacklight acts_as_taggable_on_steroids resource_controller)

inside?

Naomi Dushay added a comment - 25/Sep/09 12:41 PM
I believe this was fixed when we ditched auth_logic (to avoid dependency on bcrypt to avoid problems for windows users) and started using simplest_auth instead.