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..
- give reader
session[post_id]
when first reads post. - use
delayed_job
see if user still has session after 5 minutes. if does, markpost
- 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
Post a Comment