Skip to content


Fixed SinatraAdapter problem in rails2 branch #326

merged 3 commits into from

2 participants


Fixed a problem that was ocurring when using a Sinatra application coupled via Rack, like resque-web, and authlogic in rails2 branch on the same application. The exception raised was:

authlogic/lib/authlogic/controller_adapters/sinatra_adapter.rb:50:in included': undefined methodbefore' for Sinatra::Request:Class (NoMethodError)

Also I accidentally pushed to this branch another fix that I made. I added a session_class_namespace option, so that it is possible to define the namespace of the session class, making it easy for authlogic to find it. I can remove this if you want so.

@binarylogic binarylogic merged commit f975f52 into binarylogic:rails2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
17 lib/authlogic/acts_as_authentic/session_maintenance.rb
@@ -48,12 +48,25 @@ def session_ids(value = nil)
alias_method :session_ids=, :session_ids
+ # In some cases, you can use a different namespace for the session class. If you want to use a model
+ # to control access in a namespace and edit it in another namespace, you can define the session class
+ # namespace here so authlogic knows where to find it without problems.
+ #
+ # * <tt>Default:</tt> nil
+ # * <tt>Accepts:</tt> Strings
+ def session_class_namespace(value = nil)
+ rw_config(:session_class_namespace, value, nil)
+ end
+ alias_method :session_class_namespace=, :session_class_namespace
# The name of the associated session class. This is inferred by the name of the model.
# * <tt>Default:</tt> "#{}Session".constantize
# * <tt>Accepts:</tt> Class
def session_class(value = nil)
- const = "#{}Session".constantize rescue nil
+ namespace = rw_config(:session_class_namespace, nil)
+ const = ((namespace.nil? ? "" : "#{namespace}::") + "#{}Session").constantize rescue nil
rw_config(:session_class, value, const)
alias_method :session_class=, :session_class
@@ -136,4 +149,4 @@ def session_class
2 lib/authlogic/controller_adapters/sinatra_adapter.rb
@@ -58,4 +58,4 @@ def self.included(klass)
-Sinatra::Request.send(:include, Authlogic::ControllerAdapters::SinatraAdapter::Adapter::Implementation)
+Sinatra::Base.send(:include, Authlogic::ControllerAdapters::SinatraAdapter::Adapter::Implementation)
Something went wrong with that request. Please try again.