Class: Authorizer::UserObserver
- Inherits:
-
ActiveRecord::Observer
- Object
- ActiveRecord::Observer
- Authorizer::UserObserver
- Defined in:
- lib/authorizer/user_observer.rb
Overview
Observes users and deleted any associated ObjectRole objects when the user gets deleted.
Instance Method Summary collapse
-
#after_destroy(user) ⇒ Object
W DONT DO DIZ let’s use before_destroy instead of after_destroy.
Instance Method Details
#after_destroy(user) ⇒ Object
W DONT DO DIZ let’s use before_destroy instead of after_destroy. More chance it will still have an ID >:)))))))))) :‘) :DDDDDDDDDDDDDDDDDDDDDDD W DONT DO DIZ
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/authorizer/user_observer.rb', line 11 def after_destroy(user) # Default object_roles = [] # Find all ObjectRole records that point to this user's ID. begin object_roles = ObjectRole.find_all_by_user_id(user.id) rescue end # Walk through 'em # Not executed if anything happens (array.size = 0) for object_role in object_roles object_role.destroy end end |