Class: ActivityLog

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/activity_log/activity_log.rb

Class Method Summary collapse

Class Method Details

.create_new(user, action, object, data = {}, parent_activity_id = nil) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/activity_log/activity_log.rb', line 8

def self.create_new(user, action, object, data={}, parent_activity_id=nil)

  options = {
      "user_id" => user.id,
      "object_id" => object.id,
      "object_type" => object.class.name,
      "action" => action,
      "data" => data,
      "parent_activity_id" => parent_activity_id
  }
  log = ActivityLog.create(options)

  if log.save
    log
  else
    raise "ActivityLog failed to be saved" # TODO: this is just temporary
  end

end