Skip to content

Instantly share code, notes, and snippets.

@jlecour
Created May 23, 2011 11:09
Show Gist options
  • Save jlecour/986555 to your computer and use it in GitHub Desktop.
Save jlecour/986555 to your computer and use it in GitHub Desktop.
Touch plugin for MongoMapper
# encoding: UTF-8
module MongoMapper
module Plugins
module Touch
extend ActiveSupport::Concern
module InstanceMethods
def touch(key = :updated_at)
raise "InvalidKey" unless self.key_names.include?(key.to_s)
self.set(key => Time.now.utc)
true
end
end
end
end
end
@jlecour
Copy link
Author

jlecour commented May 23, 2011

But I prefer to store Dates/Times in UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment