150 Experience
1 Lesson Completed
0 Questions Solved


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?

Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more.

© 2024 GoRails, LLC. All rights reserved.