Skip to content

Commit

Permalink
Updated use of named_scopes to scopes when Rails 3
Browse files Browse the repository at this point in the history
  • Loading branch information
james2m authored and jjb committed Jan 7, 2011
1 parent 846b92e commit 35455c9
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/authlogic/acts_as_authentic/logged_in_status.rb
Expand Up @@ -31,9 +31,13 @@ def self.included(klass)

klass.class_eval do
include InstanceMethods

named_scope :logged_in, lambda { {:conditions => ["last_request_at > ?", logged_in_timeout.seconds.ago]} }
named_scope :logged_out, lambda { {:conditions => ["last_request_at is NULL or last_request_at <= ?", logged_in_timeout.seconds.ago]} }
if Rails::VERSION::MAJOR >= 3
scope :logged_in, where("last_request_at > ?", logged_in_timeout.seconds.ago)
scope :logged_out, where("last_request_at is NULL or last_request_at <= ?", logged_in_timeout.seconds.ago)
else
named_scope :logged_in, lambda { {:conditions => ["last_request_at > ?", logged_in_timeout.seconds.ago]} }
named_scope :logged_out, lambda { {:conditions => ["last_request_at is NULL or last_request_at <= ?", logged_in_timeout.seconds.ago]} }
end
end
end

Expand Down

0 comments on commit 35455c9

Please sign in to comment.