-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
39 lines (28 loc) · 1.27 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
Acts as Loggable
================
Simplifies the process of logging activities.
Prepare database
================
ruby script/generate log_activity_files # This command will copy 3 files: helper file, RecentActivity model, and a migration file.
rake db:migrate
Example
=======
Lets log the signup process and edit profile process
Add these lines to user.rb:
~~~~~~~~~~~~~~~~~~~~~~~~~~
acts_as_loggable
after_create :create_signup_activity
after_save :create_profile_updated_activity
def create_signup_activity
# Here '1' denotes the type of the activity i.e. user creation.
# Also :user denotes the object who creates the activity.
create_recent_activity(:user => self, :activity_type => 1)
end
def create_profile_updated_activity
if name_changed? || city_changed? || country_changed? # Create the recent activity only if any of these fields have changed.
# Here '2' denotes the type of the activity i.e. edit profile.
# If the user further updates his profile, no new record will be created. But it will simply update the time_stamp field of this record.
create_recent_activity(:user => self, :activity_type => 2, :disable_further_logging_for => 15.minutes)
end
end
Copyright (c) 2009 [Arun Kumar], released under the MIT license