collectiveidea / audited

Audited (formerly acts_as_audited) is an ORM extension that logs all changes to your Rails models.
MIT License
3.34k stars 645 forks source link

Robustify Rails version checks #689

Closed blaet closed 5 months ago

blaet commented 7 months ago

Ensure Rails versions are properly checked, instead of relying on String comparisons.

Example of why this is an issue

[8] pry(main)> Rails.version > "10.2.3"
=> true
[9] pry(main)> Gem::Version.new(Rails.version) >= Gem::Version.new("10.2.3")
=> false

This example was taken from this comment on a recent PR.

Approach

This change leverages the already existing function Rails.gem_version. This has been part of the Rails codebase for 10+ years, making it compatible with all supported Rails versions.

blaet commented 7 months ago

Fixed a small syntax error. Build should now be 🍏

blaet commented 6 months ago

Hi @danielmorrison, any chance you could have a look at this one? Thanks so much! 🚀