Skip to main content
Ask A Question
You’re not receiving notifications from this thread.

How do I mark content as "seen" or "read" when it's in the user's view?

Rails • Asked by Sam

Hi everyone,

I'm trying to mark messages as "seen" when the div has entered the user's view (for example, the Facebook behavior of seen posts). My current attempt is a mix of the Unread gem ( and the isOnScreen Jquery plugin (

But my two biggest problems are,

1) how do I get the Javascript to account for all ActiveRecord entries on a page? For instance, I can provide <div id="post-<%= %>">, but how would I test for every possible div?
2) Once the Javascript confirms that a div is in view, how do I get it to send that information to Rails (to create a record in the user_read_posts table)?

Am I approaching this the wrong way altogether?

Did you figure this out?

I too would love to know how to do this.

See my answer to the same here:

You can do two types of user interactions:

  • The one described in the above link is a button 'Mark as Read' similar to what we have here on Gorails 'Mark as Completed'.
  • The other one may be an automatic one where the page is marked as read automatically as soon as the user loads the page. In this case the difference will be in the controller. As soon as the user hits the show method, you create a journal entry that records the view.

Hope this makes sense after reading the link above.

Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 29,763+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.