ruby on rails - Checking if the user is still on the same page -


how check if user still on same page?

i want mark post if user has been reading same post longer 5 minutes. this, need check twice: when first reads post, , when 5 minutes have passed. right now, i'm thinking of doing..

  1. give reader session[post_id] when first reads post.
  2. use delayed_job see if user still has session after 5 minutes. if does, mark post
  3. whenever goes list of posts, check whether has session[post_id] , rid of it.

does logic make sense?

i'd use javascript trigger request:

<script>   $(document).on('ready', function(){     this.settimeout(function(){       $.post("/posts/update/#{@post.id}", {marked: true})     }, 1000*60*60*5)   }) </script> 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -