123456789101112131415161718192021222324252627282930313233343536 |
- module User::TouchesOrganization
- extend ActiveSupport::Concern
- included do
- after_create :touch_user_organization
- after_update :touch_user_organization
- after_destroy :touch_user_organization
- end
- private
- def touch_user_organization
-
- return true if Setting.get('import_mode')
- organization_id_changed = saved_changes['organization_id']
- return true if !organization_id_changed
- return true if organization_id_changed[0] == organization_id_changed[1]
-
- if organization_id_changed[0]
- old_organization = Organization.find(organization_id_changed[0])
- old_organization&.touch
- end
-
- organization&.touch
- true
- end
- end
|