Skip to content

Instantly share code, notes, and snippets.

@joshuapinter
Created March 16, 2015 22:11
Show Gist options
  • Save joshuapinter/92ee383bb30f3fb5c140 to your computer and use it in GitHub Desktop.
Save joshuapinter/92ee383bb30f3fb5c140 to your computer and use it in GitHub Desktop.
Activate Authlogic in Console
if defined?(ActiveRecord::Base) && defined?(Authlogic)
controller = ApplicationController.new
require 'action_controller/test_case'
controller.instance_variable_set(:@_request, ActionController::TestRequest.new)
controller.instance_variable_set(:@_response, ActionController::TestResponse.new)
Authlogic::Session::Base.controller = Authlogic::ControllerAdapters::RailsAdapter.new(controller)
end
UserSession.new( User.first )
@srogers
Copy link

srogers commented Aug 3, 2017

This looks so promising, but unfortunately, in Rails 5.1 and authlogic 3.6.0, I get:

> controller.instance_variable_set(:@_request, ActionController::TestRequest.new)
ArgumentError: wrong number of arguments (given 0, expected 3)
from /Users/steve/.rvm/gems/ruby-2.3.3@liveoak/gems/actionpack-5.1.2/lib/action_controller/test_case.rb:51:in `initialize'

and I'm pretty stumped as to what it needs.

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