Proposal: Versioned inflections

Correctly, rails/activesupport/lib/active_support/inflections.rb at main · rails/rails · GitHub has been frozen for a long time to not break backwards compat.

However there are many known exceptions (like “canvas”) that could be added to make for a better user experience out of the box

rails g model ArtCanvas name:string
[WARNING] The model name 'ArtCanvas' was recognized as a plural, using the singular 'ArtCanva' instead. Override with --force-plural or setup custom inflection rules for this noun before running the generator.
      invoke  active_record
      create    db/migrate/20241126143705_create_art_canvas.rb
      create    app/models/art_canva.rb
      invoke    test_unit
      create      test/models/art_canva_test.rb
      invoke      factory_bot
      create        test/factories/art_canvas.rb

Is it reasonable to version inflections and then move them forward with config.load_defaults in application.rb but allow something like config.active_support.inflection_version = 7.2 to allow for backwards compat.

Non-english could potentially be added in through gems.

2 Likes

Correct me if I am wrong, but I think this is why every project gets a config/initializers/inflections.rb file generated? To be able to add their own custom/project specific inflections? While Canvas is a good example, where would you draw the line on putting in AS vs having a user manage themselves?

Some may say the inflections included already are too much? I mean, does every project really need an inflection for testis/testes?

I believe there are some obvious ones like Canvas → Canva (or anything else with the singular ending as an ‘s’) that would confuse new comers and also creates difficult inconsistencies for AI tooling (which might not be a popular reason to do this).