1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
>> c = Comment.create
  Comment Create (0.6ms)   INSERT INTO "comments" ("updated_at", "body", "author", "song_id", "created_at", "state") VALUES('2009-11-09 05:18:06', NULL, NULL, NULL, '2009-11-09 05:18:06', 'pending')
=> #<Comment id: 5, song_id: nil, author: nil, body: nil, created_at: "2009-11-09 05:18:06", updated_at: "2009-11-09 05:18:06", state: "pending">
>> c.state_will_change!
=> "pending"
>> c.changed
=> ["state"]
>> c.publish!
=> true
>> c.state
=> "published"
>> c.changed
=> []
>> c.state_will_change!
=> "published"
>> c.changed
=> ["state"]
>> c.save
=> true
>> c.changed
=> []
>> Comment.last.state
  Comment Load (0.4ms)   SELECT * FROM "comments" ORDER BY comments.id DESC LIMIT 1
=> "pending"