Created
April 15, 2009 12:34
-
-
Save gravis/95741 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Render a timestamp suitable for javascript substitution (jquery.timeago) | |
# Sorry for copyright, I can't remember where I found this piece of code ! Do not hesitate to claim it | |
def timeago(time, options = {}) | |
options[:class] ||= "timeago" | |
content_tag(:abbr, time.to_s, options.merge(:title => time.getutc.iso8601)) if time | |
end | |
# don't forget to add this to substitute times (HAML) : | |
# :javascript | |
# $(document).ready(function() { | |
# $('abbr[class*=timeago]').timeago(); | |
# }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment