rails-livestamp is a simple jQuery plugin that makes it easy to provides automatically updating text to your timestamped HTML elements.
Installation
Add this line to your application’s Gemfile:
1
|
|
And then execute:
1
|
|
Or install it yourself as:
1
|
|
To use rails-livestamp add this require statement to your application.js file:
1
|
|
Usage
No extra JavaScript required! Just use a with the data-livestamp attribute set to the desired Unix timestamp (in seconds), like this:
If you use ERB:
1
|
|
If you use HAML:
1 2 |
|
And you will see something like this:
1
|
|
Wait half a minute - the livestamp will update automatically.