A Ruby on Rails gem to manage read/unread status of ActiveRecord objects with high performance.
Unread is a Ruby gem that manages read and unread statuses for ActiveRecord objects in Ruby on Rails applications. It solves the problem of tracking which records (like messages, documents, or comments) a user has read, providing scopes and methods to query and update read states efficiently. The gem is designed for performance, using a single additional database table and optimized SQL queries.
Ruby on Rails developers building applications that need to track user read states, such as messaging systems, notification feeds, or content platforms where read/unread status is essential.
Developers choose Unread for its high performance, simplicity, and scalability. It offers a clean API, minimal database overhead, and efficient queries, making it suitable for large datasets without the complexity of alternative solutions.
Handle unread records and mark them as read with Ruby on Rails
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Uses efficient LEFT JOIN queries and a single read_marks table, optimized for large datasets as shown in the README's SQL example.
Configurable 'on' option allows using fields like created_at or updated_at, preventing unwanted unread status changes on record updates.
Provides intuitive scopes like unread_by and read_by, and methods like mark_as_read!, making integration into Rails models straightforward.
Includes mark_as_read! :all for bulk operations and cleanup_read_marks! method to manage table growth, though it requires manual maintenance.
The read_marks table can grow indefinitely without regular cleanup, requiring a cron job as admitted in the README, adding operational overhead.
Only works with ActiveRecord in Rails, not compatible with other Ruby ORMs or frameworks, limiting its use in mixed-stack applications.
Requires generating and running a migration, adding database indexes on timestamp fields, and adhering to specific Ruby and Rails version requirements.