From 4d591da87d3dc43e25f8ede08d3806e909198630 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 16 Apr 2012 13:57:33 +0200 Subject: [PATCH] Added caching / delete of caches if user object changes. --- app/models/authorization.rb | 6 +++++- app/models/group.rb | 5 ++++- app/models/role.rb | 5 ++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/models/authorization.rb b/app/models/authorization.rb index 9e9b1f0c9..739eae3a9 100644 --- a/app/models/authorization.rb +++ b/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 diff --git a/app/models/group.rb b/app/models/group.rb index 217c0d7e4..4c46900af 100644 --- a/app/models/group.rb +++ b/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 diff --git a/app/models/role.rb b/app/models/role.rb index 33cd819ac..4248f70be 100644 --- a/app/models/role.rb +++ b/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