Avoid rails helper times_ago_in_words()

Let's say we have 100 records in lessons table then
%td.last_modified= times_ago_in_words(lesson.updated_at)
server calculate the time ago for each record for each request, it wastes a lot of time on server side.
If we replace above code by
%td.last_modified"= lesson.updated_at.to_s
and load jquery plugin

<script src="jquery.timeago.js" type="text/javascript"></script>

then in JavaScript
$("td.last_modified").timeago()
thats it.
Then the javascript will calculate the time ago on client side after loading the page in browser.
So you can enhance your app response time.

For more info about timeago jquery plugin [click here(click here)][1]

Thanks
[1]: http://timeago.yarp.com/

Sunil Sharma

I am a Ruby on Rails developer, passionate about building interesting and innovative web and mobile apps. | Ruby on Rails | Ember.js | Cordova | Travelling | Party | Trekking ...

Read More