Browse Source

Added caching / delete of caches if user object changes.

Martin Edenhofer 13 years ago
parent
commit
4d591da87d
3 changed files with 13 additions and 3 deletions
  1. 5 1
      app/models/authorization.rb
  2. 4 1
      app/models/group.rb
  3. 4 1
      app/models/role.rb

+ 5 - 1
app/models/authorization.rb

@@ -1,8 +1,12 @@
-class Authorization < ActiveRecord::Base
+class Authorization < ApplicationModel
   belongs_to              :user
   validates_presence_of   :user_id, :uid, :provider
   validates_uniqueness_of :uid,     :scope => :provider
   
+  after_create            :cache_delete
+  after_update            :cache_delete
+  after_destroy           :cache_delete
+  
   def self.find_from_hash(hash)
     auth = Authorization.where( :provider => hash['provider'], :uid => hash['uid'] )
     if auth && auth.first then

+ 4 - 1
app/models/group.rb

@@ -1,3 +1,6 @@
-class Group < ActiveRecord::Base
+class Group < ApplicationModel
   has_and_belongs_to_many :users
+  after_create            :cache_delete
+  after_update            :cache_delete
+  after_destroy           :cache_delete
 end

+ 4 - 1
app/models/role.rb

@@ -1,3 +1,6 @@
-class Role < ActiveRecord::Base
+class Role < ApplicationModel
   has_and_belongs_to_many :users
+  after_create            :cache_delete
+  after_update            :cache_delete
+  after_destroy           :cache_delete
 end