RubyMoney/money-rails
64.7
Adequate · 19 September 2026
1k
lines of production code
Ruby
primary language
1
measurement over time
What this system is
This system is a Ruby gem that integrates the Money library into Rails and Mongoid applications to handle monetary values. It provides ActiveRecord and Mongoid macros for monetizing attributes, including automatic database column generation and validation. The gem also offers Action View helpers for formatting currency in templates and an ActiveJob serializer for background job processing. Additionally, it supports non-Rails environments and allows for comprehensive configuration of default currencies, rounding, and formatting rules.
How it got here
2012 — Rails Engine architecture and test infrastructure
20 changes.
The project underwent a major architectural rewrite to become a proper Rails Engine, introducing a centralized configuration system, new view helpers, and refactored ActiveRecord monetization. This period focused heavily on establishing a robust testing foundation by creating a dummy Rails application and comprehensive test suites for configuration, migrations, and validation logic.
2013–2026 — Mongoid and ActiveJob integration updates
6 changes.
This period focused on enhancing the Money gem's compatibility with modern Rails and Mongoid versions, including support for Rails 7.0–8.1 and Mongoid 7–9. Key features included a new ActiveJob serializer for seamless background job processing and refined Mongoid serialization that stores values as hashes for improved data consistency. The work was supported by comprehensive test coverage for these integrations and a shift to Bundler binstubs for development tooling.
Features
Add ActiveJob serializer for Money objects
Users can now pass Money objects directly to ActiveJob jobs and sidekiq queues without manual serialization. A new MoneySerializer handles the conversion of Money instances to a hash of cents and currency during serialization, and reconstructs the Money object upon deserialization, ensuring seamless integration with background job processing.
_lib/money-rails/active\job · high confidence
Add generator for MoneyRails initializer
Users can now run a generator to create a sample MoneyRails initializer file at config/initializers/money.rb, simplifying the setup process for configuring the money.rb library within a Rails application.
_lib/generators/money\rails · high confidence
Add generator for MoneyRails initializer template
Users can now install a comprehensive configuration file for MoneyRails via a new generator. The generated \money.rb\ initializer provides commented-out examples and documentation for key settings, including default currency, exchange rate banks, validation inclusion, migration column configurations, custom currency registration, rounding modes, default formatting, locale backend selection, and error handling for money parsing.
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 new view helpers for displaying monetary amounts. Users can now use \currency\_symbol\ to display a currency's symbol, \humanized\_money\ and \humanized\_money\_with\_symbol\ to format money values with optional configuration (such as \no\_cents\_if\_whole\ and \disambiguate\), \money\_without\_cents\ to display amounts without fractional units, and \money\_only\_cents\ to display just the cents portion of a value. These helpers integrate with the existing \Money\ and \MoneyRails::Configuration\ classes to provide consistent formatting in views.
lib/money-rails/helpers · high confidence
New ActiveModel validator for monetized attributes
Introduces a new \MoneyValidator\ class that extends \NumericalityValidator\ to handle validation of money attributes. This validator processes raw string inputs by stripping currency symbols, normalizing decimal and thousands separators based on the locale backend, and rejecting invalid formats (such as misplaced thousands separators or multiple decimal points). It also ensures compatibility with the standard \validates\ method by registering itself in the \ActiveModel::Validations\ namespace.
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
Library now supports non-Rails environments
The main library entry point now conditionally loads Rails-specific components (the Railtie and Engine) only when the Rails framework is present, allowing the gem to function in non-Rails Ruby applications. It also adds conditional support for RailsAdmin if that gem is detected.
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 proper Rails Engine, introducing a centralized configuration module that allows global settings for default currency, rounding mode, validation inclusion, and formatting options (symbol, sign placement, no-cents behavior). It adds a new \MoneyRails::Error\ class for consistent error handling, integrates with ActiveJob for Money serialization, and provides a comprehensive RSpec test helper (\monetize\ matcher) with support for \allow\_nil\. The Rails Admin integration now uses a Decimal-based field type, and the library enforces PostgreSQL adapter compatibility by always requiring the PG version while gracefully handling non-PG environments. This is a significant architectural shift from previous versions, moving away from legacy alias\_method\_chain patterns and simplifying the loading mechanism via hooks.
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
Refactored migration extensions for cleaner money column handling
The migration extension logic has been reorganized to improve maintainability and consistency. A new \OptionsExtractor\ class centralizes the logic for deriving column names, types, and constraints from configuration and user options. The previous implementation details have been split into distinct modules: \SchemaStatements\ and \Table\ provide the public-facing \add\_money\/\remove\_money\ and \money\/\remove\_money\ helpers, while their PostgreSQL-specific counterparts (\SchemaStatementsPg\ and \TablePg\) implement the actual database operations by leveraging the extractor. This change ensures that adding or removing money columns (amount and currency) is handled through a unified, DRY code path.
_lib/money-rails/active\_record/migration\extensions · high confidence
Test coverage
Added comprehensive test suite for ActiveRecord monetization; Added comprehensive test suite for MoneyRails configuration and helpers; Added database cleaning configuration for RSpec tests; 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 Mongoid integration; 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
Housekeeping
Project bootstrapping and RuboCop linting setup
The repository has been initialized with essential configuration files, including a Gemfile.default for development dependencies, a Rakefile for test execution, and a .rubocop.yml configuration to enforce code style using RuboCop and its performance, RSpec, and Rake plugins. A .rubocop\_todo.yml file is also included to track existing offenses, alongside standard project files like .gitignore, .rspec, and a comprehensive CHANGELOG.md documenting the history from version 0.1.0 to 3.0.0.
(repo-wide) · 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 65.
Lenses
- Code Health 96
- Architecture 69
- Maturity 55
- Readiness 65
- Security 99
Changes since last survey
- 300 commits — 242 feature/other, 58 fixes
By area
- (root) — 125 commits
- (repo) — 73 commits
- lib/money-rails — 42 commits
- .github/workflows — 20 commits
- spec/dummy — 16 commits
- spec/active_record — 6 commits
- gemfiles/mongoid2.gemfile — 3 commits
- spec/helpers — 3 commits
- spec/mongoid — 3 commits
- config/locales — 2 commits
- gemfiles/mongoid4.gemfile — 1 commit
- gemfiles/mongoid6.gemfile — 1 commit
- gemfiles/mongoid8.gemfile — 1 commit
- lib/generators — 1 commit
- spec/configuration_spec.rb — 1 commit
- spec/money_spec.rb — 1 commit
- test/minitest_compatibility_test.rb — 1 commit
Notable commits
- fix: Add CHANGELOG entry for ActionViewExtension eager loading fix
- fix: Adds money_only_cents fix to changelog
- fix: Fix ActionViewExtension not available during eager loading
- fix: Fix CI badge
- fix: Fix deprecation warning on MoneySerializer to support future Rails 8.2 (#730)
- fix: Fix failing specs on old rubies (#607)
- fix: Fix flakiness in Mongoid 3 & 4 specs
- fix: Fix for ruby-1.9.3
- fix: Fix monetize requirement for 2.0.0
- fix: Fix monetized_attributes class discrepancy
- fix: Fix rake task names for testing against gemfiles (#740)
- fix: Fix specs deprecation errors
- fix: Fix validator race condition (#591)
- fix: Fix/ci lint and jruby (#785)
- fix: Fixes #money_only_cents for negative money
- fix: Lint: Fix "Redundant" cops (#750)
- fix: Lint: Fix Lint cops (#756)
- fix: Lint: Fix Lint/ConstantDefinitionInBlock cop (#759)
- fix: Lint: Fix Naming/PredicateMethod cop (#742)
- fix: Lint: Fix RSpec cops (#766)
- …and 280 more
Architecture
- 0 containers · 1 bounded contexts · 0 dependency edges (baseline)
Written by watchdog.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 19 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 406c0b67d0636372e972824fc3380fc1f56b6da2 — 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-13a154b7f5d1.