Skip to content
CAI
Software that uses CAICheck a score

brendon/ranked-model

50.6

Adequate · 20 September 2026

381

lines of production code

Ruby

primary language

1

measurement over time

CAI band scale
CAI lens gauges

What this system is

RankedModel is a Ruby gem that provides row sorting capabilities for ActiveRecord models within Rails applications. It enables the maintenance of multiple ordered lists per model through a dedicated DSL, automatically handling rank updates, rebalancing, and validation upon save. The library supports complex scenarios including Single Table Inheritance, custom scoping, and reserved SQL keywords, while ensuring compatibility across a wide range of Rails and Ruby versions.

How it got here

2011 — Initial gem release and test infrastructure

10 changes.

This period focused on the initial release of the RankedModel gem, establishing its core functionality for maintaining multiple ordered lists in Rails applications. The work included setting up the gem structure, implementing Railtie integration, and building comprehensive test coverage to validate ranking logic, edge cases, and Single Table Inheritance support.

2013–2018 — Rails compatibility and test coverage

4 changes.

The project focused on expanding test coverage for specific model functionalities, including Ego, Player, and Number models, to ensure robust handling of ranking and reserved keywords. Concurrently, it established multi-version support by adding Appraisal gemfiles for Rails 5.2 through 7.0, verifying compatibility across various ActiveRecord versions and database adapters.

Features

Initial release of RankedModel gem with multi-ranker support

This change introduces the RankedModel gem, enabling ActiveRecord models to maintain multiple ordered lists (rankers) via the \ranks\ DSL method. It provides public accessors for position (\name\_position\) and rank (\name\_rank\), automatically handles ranking updates on save, and validates that ranked columns do not have database defaults. The implementation supports signed 32-bit integer ranges for rank values and includes a Railtie for Rails integration.

lib · high confidence

Initial release of ranked-model gem with Rails 4.2–7.0 support

This change introduces the ranked-model gem, a row sorting library for Rails applications. It adds the core gemspec, license, and Rakefile, along with a comprehensive CI configuration (Appraisals and .travis.yml) that enables testing across Rails versions 4.2 through 7.0 and Ruby versions 2.4 through 3.0 (including JRuby). The initial release includes documentation and configuration files necessary for users to integrate the gem into their projects.

(repo-wide) · high confidence

Rails integration for ranked-model

The application now automatically loads the ranked-model Railtie when the Rails framework initializes, enabling the gem's functionality within the Rails environment without requiring manual configuration.

rails · high confidence

Behavioural changes

RankedModel v0.4.11 introduces Railtie integration and refined ranking logic

This update brings RankedModel to version 0.4.11, adding a new Railtie (\lib/ranked-model/railtie.rb\) to initialize the gem within Rails applications. The core ranking behavior in \ranker.rb\ has been refined to handle edge cases more robustly, including support for string-based position values ('first', 'last', 'middle'), improved handling of up/down ordering, and fixes for SQL syntax errors and unbounded queries. The gem now also validates that records are persisted before attempting rank rebalancing and ensures unique indexes are respected during rank updates.

lib/ranked-model · high confidence

Test coverage

Added test coverage for ActiveSupport notifications and test infrastructure; Added test coverage for STI model ranking behavior; Added test coverage for ranked model edge cases and validation; Added test database configuration and schema for ActiveRecord specs; Added test for updating rank of existing player record; Added tests for Ego model ranking functionality; Added tests for keyword column name handling in Number model; Added tests for the ranker's \unless\ option and rank rebalancing bounds.

Dependencies

Added Appraisal gemfiles for Rails 5.2, 6.0, 6.1, and 7.0

The project now includes dedicated Appraisal gemfiles to support testing against ActiveRecord versions 5.2, 6.0, 6.1, and 7.0. These files configure the appropriate database adapters (SQLite, PostgreSQL, MySQL) and their JRuby equivalents for each Rails version, enabling compatibility verification across these specific framework releases.

gemfiles · high confidence

Initial gemspec and Gemfile setup for ranked-model

The project introduces a standard Ruby gem structure with a new \ranked-model.gemspec\ and \Gemfile\. The gemspec defines the library as an acts\_as\_sortable replacement for Rails 4.2+ (with a runtime dependency on ActiveRecord \>= 5.2) and lists development dependencies including RSpec, database\_cleaner, and appraisal. The Gemfile configures the gemspec as the source and adds specific database adapter gems (sqlite3, pg, mysql2) for testing purposes.

(dependencies) · high confidence

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Baseline

  • First survey — no prior run to compare against. CAI 51.

Lenses

  • Code Health 98
  • Architecture 69
  • Maturity 23
  • Readiness 68
  • Security 96

Changes since last survey

  • 209 commits — 184 feature/other, 25 fixes

By area

  • (root) — 94 commits
  • lib/ranked-model — 53 commits
  • (repo) — 30 commits
  • lib/ranked-model.rb — 9 commits
  • .github/workflows — 6 commits
  • spec/duck-model — 6 commits
  • spec/sti-model — 5 commits
  • spec/support — 2 commits
  • .github/FUNDING.yml — 1 commit
  • .github/dependabot.yml — 1 commit
  • gemfiles/rails_3_2.gemfile — 1 commit
  • spec/player-model — 1 commit

Notable commits

  • fix: A similar fix to the bug found in #23 from @quake - rearrange ranks needs to use finder
  • fix: Add license to gemspec. Fixes #48
  • fix: Changing position marks record as changed. Fixes #49
  • fix: Drop quoted columns in SET clauses. Fixes #64, Reverts #60.
  • fix: Explicitly set the accessor for position to be public, helps 1.9 compat. Fixes #6
  • fix: Fix #90: escape column name in Ranker#rearrange_ranks (#125)
  • fix: Fix DB specification example to reflect value in database.yml
  • fix: Fix an SQL syntax error in Ranker#relative_rank (#173)
  • fix: Fix assigned but unused variable warnings (#156)
  • fix: Fix error when changing with_same and rebalancing (#160)
  • fix: Fix for bundler
  • fix: Fix for ranking by STI parent
  • fix: Fix issue with consecutive final two ranks and setting rank to second to last (#130)
  • fix: Fix license in gemspec
  • fix: Fix postgresql non-determinite order
  • fix: Fix sqlite version requirement
  • fix: Fix unbounded query when giving position :last (#179)
  • fix: Fix: private method `row_position=' called
  • fix: Fixed memoization of RankedModel::Ranker::Mapper#finder
  • fix: Merge pull request #120 from brendon/fix-memoization
  • …and 189 more

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

brendon/ranked-model was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 20 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit 8b9c2790eabea2108b7e486f7d6de28e604d8b73 — the exact code this score is about.
  • Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
  • Measured by watchdog.canine.dev using codehealth-analyzer preprod-b51f968c9b10.