Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fixed SinatraAdapter problem in rails2 branch #326

Merged
merged 3 commits into from

2 participants

@efreesen

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
This page is out of date. Refresh to see the latest.
View
17 lib/authlogic/acts_as_authentic/session_maintenance.rb
@@ -48,12 +48,25 @@ def session_ids(value = nil)
end
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> "#{klass.name}Session".constantize
# * <tt>Accepts:</tt> Class
def session_class(value = nil)
- const = "#{base_class.name}Session".constantize rescue nil
+ namespace = rw_config(:session_class_namespace, nil)
+
+ const = ((namespace.nil? ? "" : "#{namespace}::") + "#{base_class.name}Session").constantize rescue nil
rw_config(:session_class, value, const)
end
alias_method :session_class=, :session_class
@@ -136,4 +149,4 @@ def session_class
end
end
end
-end
+end
View
2  lib/authlogic/controller_adapters/sinatra_adapter.rb
@@ -58,4 +58,4 @@ def self.included(klass)
end
end
-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.