-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
40 lines (27 loc) · 988 Bytes
/
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
40
Inspired by http://github.com/hashrocket/acts_as_featured/
ActsAsCompleted
==============
Allows ActiveRecord models to be specified as completed by updating a `completed_at` datetime (or timestamp) field on the model.
Also provides named scopes for completed and uncompleted finds.
Requires Rails > 2.1.0
Installation
============
Add a `completed_at` datetime field to any model that you want to be completed.
Example
=======
# Add the column
./script/generate migration AddCompletedAtToTask completed_at:datetime
rake db:migrate
class Task < ActiveRecord::Base
acts_as_completed
end
Task.completed
# SELECT * FROM tasks WHERE tasks.completed_at IS NOT NULL
Task.uncompleted
# SELECT * FROM tasks WHERE tasks.completedd_at IS NULL
@task.complete!
# UPDATE tasks SET completed_at = '2008-07-08 15:58:34' WHERE id = 1
@task.uncomplete!
# UPDATE tasks SET completed_at = NULL WHERE id = 1
@task.completed?
# Return true if the task is completed, false if not