Initial commit to the repo
[kwestie.git] / app / models / user_action_observer.rb
blobdb254c3405efff780ca1362e54e5efb7837919d3
1 class UserActionObserver < ActiveRecord::Observer
2   observe Issue, Comment
3   
4   cattr_accessor :current_user
5   
6   def before_create(model)
7     begin
8       model.created_by = @@current_user
9     rescue
10       # ignore if the model doesn't have created_by
11     end
12     begin
13       model.updated_by = @@current_user
14     rescue
15       # ignore if model doesn't have updated_by
16     end
17   end
18   
19   def before_update(model)
20     begin
21       model.updated_by = @@current_user
22     rescue
23       # ignore if the model doesn't have updated_by
24     end
25   end
26 end