Skip to content

Commit

Permalink
adjust access to anonymous user so as not to trigger db access at ini…
Browse files Browse the repository at this point in the history
…tialization time
  • Loading branch information
leword committed Mar 9, 2009
1 parent 38433ec commit 4f9c490
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/models/role.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
class Role < ActiveRecord::Base
acts_as_card_extension
has_and_belongs_to_many :users
@@anonymous_user = User.new(:login=>'anonymous')
def self.anonymous_user
@@anonymous_user ||= User.new(:login=>'anonymous')
end

cattr_accessor :cache
self.cache = {}
Expand All @@ -13,7 +15,7 @@ def users_with_special_roles
if codename=='auth'
User.active_users
elsif codename=='anon'
User.active_users + [@@anonymous_user]
User.active_users + [self.class.anonymous_user]
else
users_without_special_roles
end
Expand Down

0 comments on commit 4f9c490

Please sign in to comment.