A Ruby gem that generates scoped sequential IDs for ActiveRecord models to avoid exposing primary keys in URLs.
Sequenced is a Ruby gem that generates scoped sequential IDs for ActiveRecord models. It solves the problem of exposing database primary keys in URLs by providing an alternative, sequential identifier that is unique within a specific scope, such as records belonging to a parent object.
Ruby on Rails developers building applications where they need to present records with user-friendly, sequential numbers (like issue tracking, nested comments, or survey answers) without revealing internal database keys.
Developers choose Sequenced for its simplicity and seamless integration with ActiveRecord—adding sequential IDs with just one line of code—while maintaining data integrity through support for database constraints and concurrent safety in PostgreSQL.
Generate scoped sequential IDs for ActiveRecord models
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Easily generates sequential IDs within a specific parent context, such as answers numbered per question, ideal for nested resources without exposing primary keys.
Supports custom column names, dynamic start points with lambdas, and conditional skipping via options like `column`, `start_at`, and `skip`, allowing tailored sequencing logic.
Encourages adding unique indexes and not-null constraints to prevent duplicates and ensure data consistency, with clear migration examples provided in the README.
Can scope sequences by multiple columns for polymorphic relationships, enabling complex association models like answers belonging to various parent types.
Only guarantees concurrent safety for PostgreSQL databases; using MySQL or SQLite can lead to race conditions during concurrent writes, requiring manual error handling.
Adding sequenced columns to existing tables requires non-trivial SQL updates in migrations, as shown with raw SQL using ROW_NUMBER(), which adds setup overhead.
Tightly integrated with ActiveRecord, making it unsuitable for applications using other ORMs or data layers, limiting framework flexibility.