RubyMoney/money-rails
62.8
Adequate · 6 November 2026
1k
lines of production code
Ruby
primary language
4
measurements over time
What this system is
This system is a Ruby gem that integrates monetary value handling into Rails and Mongoid applications. It provides ActiveRecord and Mongoid macros to monetize model attributes, ensuring consistent storage and validation of currency amounts. The library also offers Action View helpers for formatting money in views and supports ActiveJob serialization for asynchronous processing.
How it got here
2012 — Rails Engine rewrite and test infrastructure
21 changes.
The project underwent a major architectural shift by restructuring as a Rails Engine with a centralized configuration system and lazy-loaded integrations. This release introduced comprehensive test coverage, including a dummy Rails application and extensive specs for configuration, helpers, and migration extensions. Additionally, new features such as Action View formatting helpers and an ActiveModel validator were added to enhance usability and validation capabilities.
2013–2026 — Modern framework compatibility and serialization
8 changes.
The project expanded support for recent Rails (7.0–8.1) and Mongoid versions while refining data storage formats for improved consistency. New features include native ActiveJob serialization for Money objects, and the test suite was significantly reorganized and expanded to cover these integrations and configuration options.
Features
ActiveJob serialization support for Money objects
Users can now pass Money objects directly to ActiveJob jobs and sidekiq queues without manual conversion. A new MoneySerializer handles serialization by storing the amount in cents and the currency code, and deserializes them back into Money instances, ensuring consistent handling of monetary values across asynchronous jobs.
_lib/money-rails/active\job · high confidence
Add generator for MoneyRails initializer
Users can now run the \money\_rails:install\ generator to create a sample MoneyRails initializer file at \config/initializers/money.rb\, simplifying the initial setup process for the library.
_lib/generators/money\rails · high confidence
Add money.rb initializer template with comprehensive configuration options
Users can now install a new initializer template that provides a fully commented configuration file for MoneyRails. This template exposes options for setting the default currency and bank, adding exchange rates, enabling validations for monetized fields, customizing database column names and types for amounts and currencies, registering custom currencies, specifying rounding modes, defining global money formats, selecting a locale backend (I18n, currency-specific, or none), and controlling error raising on currency parsing mismatches.
lib/generators/templates · high confidence
New Action View helpers for formatting money values
This change introduces a new \ActionViewExtension\ module in \lib/money-rails/helpers/action\_view\_extension.rb\, providing several helpers for displaying monetary values in views. The \humanized\_money\ helper formats money objects with configurable options such as \no\_cents\_if\_whole\ and \symbol\, while \humanized\_money\_with\_symbol\ is a convenience wrapper that always includes the currency symbol. Additional helpers include \money\_without\_cents\ and \money\_without\_cents\_and\_with\_symbol\ for displaying amounts without fractional units, and \money\_only\_cents\ for displaying just the cents portion of a value. These helpers support both \Money\ objects and values that respond to \to\_money\, ensuring flexible integration with existing models.
lib/money-rails/helpers · high confidence
New ActiveModel MoneyValidator for string input validation
The money-rails gem now includes a dedicated MoneyValidator that extends ActiveModel's NumericalityValidator to handle string-based monetary inputs. This validator normalizes values by removing currency symbols, whitespace, and underscores, while respecting locale-specific decimal marks and thousands separators. It performs specific checks to reject invalid formats, such as thousands separators appearing after the decimal mark or incorrect grouping lengths, and integrates with Money.locale\_backend for i18n support. The validator is also registered in the ActiveModel::Validations namespace to ensure compatibility with the standard validates method.
money-rails · high confidence
Behavioural changes
Add support for Rails 7.0–8.1 and Mongoid 7–9
The gemfiles directory now includes dedicated lockfiles for Rails versions 7.0, 7.1, 7.2, 8.0, and 8.1, as well as Mongoid versions 7, 8, and 9. This allows users to run the test suite against these specific versions of the underlying frameworks, ensuring compatibility with the latest releases of ActiveRecord and Mongoid.
gemfiles · high confidence
Adopt Bundler binstubs for development tools
The project now uses Bundler-generated binstubs for Rake, RSpec, and RuboCop in the bin directory. This change replaces the previous practice of invoking these tools via \bundle exec\, allowing them to be run directly by name while ensuring they execute within the context of the project's Gemfile dependencies.
bin · high confidence
Introduce RuboCop linting and standardized development environment configuration
The project now enforces code quality and consistency by adding a comprehensive RuboCop configuration (\.rubocop.yml\) with plugins for RSpec, Rake, and performance, alongside a generated \.rubocop\_todo.yml\ to track existing offenses. A new \Gemfile.default\ establishes a standardized development environment, including specific linting gems and test dependencies. Additionally, a new \Rakefile\ provides tasks to run specs against multiple Rails and ORM versions via dedicated gemfiles, and a \spec:prepare\_test\_env\ task to set up the dummy database. Repository hygiene is improved with new \.gitignore\ and \.gitattributes\ files to exclude generated artifacts and lock files.
(repo-wide) · high confidence
Lazy registration of framework integrations
The library now registers its Active Record and Action View integrations using lazy load hooks instead of immediate inclusion. This ensures that the monetization and helper features are only attached to classes when the respective frameworks are actually loaded, preventing errors during eager loading or when the gem is used in non-Rails environments.
lib · high confidence
Money-rails v3.0.0: Major rewrite with Rails Engine architecture and new configuration system
This release restructures money-rails as a Rails Engine, introducing a centralized configuration module that allows global settings for default currency, rounding mode, validation inclusion, and formatting options (symbol, sign placement, default format). It adds support for custom currency registration, ActiveJob serialization for Money objects, and a new RSpec test helper with an \allow\_nil\ option. The Rails Admin integration now uses a Decimal-based field type, and the library enforces PostgreSQL adapter compatibility while maintaining backward compatibility for non-PostgreSQL databases. Version is bumped to 3.0.0.
lib/money-rails · high confidence
Refactored ActiveRecord monetization with per-attribute validation control and inheritance support
The \monetize\ macro in ActiveRecord models has been refactored to improve flexibility and correctness. Users can now disable validations for specific attributes using the \disable\_validation\ option, and the system supports inheriting monetized attributes from parent classes. The implementation also fixes issues with \before\_type\_cast\ handling for subunit fields, ensures proper currency column inference via postfixes, and raises clear errors when attribute names conflict or cannot be inferred.
_lib/money-rails/active\record · high confidence
Refined Mongoid serialization and error handling for Money fields
The Mongoid integration for Money fields has been updated to store values as a hash containing float cents and ISO currency codes, replacing previous string-based storage. This change improves data consistency by handling blank form inputs gracefully (returning nil instead of zero) and adding specific error handling for unknown currencies and parse errors, which can now be configured to raise a generic MoneyRails::Error or return nil based on application settings.
lib/money-rails/mongoid · high confidence
Fixes
Fixes null option handling in money migration helpers
The migration extension logic now correctly respects a top-level \null\ option when creating or removing money columns, ensuring that this setting applies to both the amount and currency columns unless overridden by per-attribute options. This change refactors the \OptionsExtractor\ and schema statement modules to properly merge configuration defaults with user-provided options, fixing previous behavior where the \null\ constraint might have been ignored or mishandled during schema generation.
_lib/money-rails/active\_record/migration\extensions · high confidence
Test coverage
Added comprehensive test suite for MoneyRails configuration and helpers; Added database cleaning configuration for RSpec tests; Added dummy Rails application configuration for testing; Added dummy Rails application for testing; Added test coverage for ActionView and form helpers; Added test coverage for dummy app environment configurations; Added test suite for MoneyRails initializer configuration; Added testbed infrastructure and error page assets; Added tests for ActiveJob Money serializer; Added tests for ActiveRecord migration extensions; Added tests for MoneyRails configuration and load hooks; Added tests for Mongoid integration; Refactor monetizable test suite into focused spec files; Refactored monetizable specs into a dedicated test file; Updated dummy database schema for Rails 7.0.
Dependencies
Update dependencies to Money 7.0 and Rails 7.0+
The gemspec now requires Ruby 3.1 or higher and updates the core dependencies to Money \~\> 7.0 and Monetize \~\> 2.0, while restricting support to Rails 7.0+ (via activesupport and railties). The Gemfile has been refactored to dynamically load version-specific gemfiles based on the Ruby version (ActiveRecord 8.1 for Ruby 3.2+, otherwise ActiveRecord 7.0), and metadata fields including MFA requirements have been added to the gemspec.
(dependencies) · high confidence
Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Score
- CAI 64 → 63 (-0.8)
- Rubric changed (rubric-2026.10.5 → rubric-2026.11.2) — scores are not directly comparable.
Lenses
- Code Health 74 → 74 (+0.0)
- Architecture 69 → 69 (+0.0)
- Maturity 55 → 54 (-1.6)
- Readiness 67 → 67 (+0.0)
- Security 99 → 98 (-0.7)
Resolved (3)
- Ambiguous distinction between similar view helpers. While 'with_symbol' is explicit, 'humanized_money' might imply inclusion of the symbol or not depending on global configuration. This creates confusion for developers who must guess the default behavior or check documentation to ensure the symbol is included/excluded.
- Duplicate intent with inconsistent naming. 'add_money'/'money' and 'add_monetize'/'monetize' appear to perform the same database migration operation (adding a money column and associated subunit/currency columns). The library exposes two parallel sets of methods for the same underlying schema change, likely due to historical naming changes or aliases, but exposes both without clear deprecation or distinction.
- Duplicate intent with inconsistent naming. Similar to the add operations, 'remove_money' and 'remove_monetize' are duplicated across SchemaStatements and Table contexts. This forces users to choose between two synonymous methods for dropping money columns.
Architecture
- Unchanged — 0 containers · 1 contexts · 0 edges
Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
RubyMoney/money-rails 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 6 November 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit d577b19084a27340ceca3a809940f49e151d50cd — the exact code this score is about.
- Scored under rubric-2026.11.2 — the same rubric and the same method as every other entry in this index.
- Measured by Canine Code Analyzer (cca.canine.dev) using cca measure-2026.11.2+preprod-5c4e66d9318b.