Skip to content

Instantly share code, notes, and snippets.

@lulalala
Created August 16, 2012 07:34
Show Gist options
  • Save lulalala/3368106 to your computer and use it in GitHub Desktop.
Save lulalala/3368106 to your computer and use it in GitHub Desktop.
Need to reset change twice for it to be marked unchanged
>> t = Topic.find(47083); time = t.event.end
Topic Load (9.2ms) SELECT `topics`.* FROM `topics` WHERE `topics`.`id` = 47083 LIMIT 1
Topic::Event Load (0.5ms) SELECT `periods`.* FROM `periods` WHERE `periods`.`type` IN ('Topic::Event') AND `periods`.`owner_id` = 47083 AND `periods`.`owner_type` = 'Topic' LIMIT 1
=> Thu, 16 Aug 2012 09:00:04 CST +08:00
>> t.event.changed?
=> false
>> t.event.end = time + 1.second
=> Thu, 16 Aug 2012 09:00:05 CST +08:00
>> t.event.end_changed?
=> true
>> t.event.reset_end!
=> Thu, 16 Aug 2012 09:00:04 CST +08:00
>> t.event.end_changed?
=> true
>> t.event.end_change
=> [Thu, 16 Aug 2012 09:00:04 CST +08:00, Thu, 16 Aug 2012 09:00:04 CST +08:00]
>> t.event.reset_end!
=> Thu, 16 Aug 2012 09:00:04 CST +08:00
>> t.event.end_changed?
=> false
>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment