implementing ActiveSupport::Concern loading optimization included modules in Rails 7
This might be a silly question, but I'm migrating some code and Hey everyone, I'm running into an issue that's driving me crazy. I'm working with a peculiar scenario with `ActiveSupport::Concern` in my Rails 7 application. I have a module that I expect to be included in my model, but it seems that the methods from the module are not available. Here's a simple outline of what I have: ```ruby module MyConcern extend ActiveSupport::Concern included do before_save :normalize_name end def normalize_name self.name = name.strip.titlecase end end class User < ApplicationRecord include MyConcern end ``` When I try to save a user with a name that has extra spaces, it doesn't normalize the name as expected. I checked the logs and I see that the `before_save` callback is not being triggered, which leads me to believe that `MyConcern` is not being included properly. I have tried restarting the Rails server, and I also verified that `MyConcern` is loaded by placing a simple `puts` statement inside the `included` block to ensure it executes. The output appears in the console, so the module seems to load correctly. However, when I instantiate a user and call `save`, the callback does not fire, and I get the following behavior: ``` NoMethodError: undefined method `normalize_name' for #<User:0x00007ff9b58a12b8> ``` I've also double-checked that the `User` model is not being reloaded in any way that would prevent the concern from being included. Am I missing something else that would prevent the inclusion of the module, or is there a known scenario with `ActiveSupport::Concern` in Rails 7? Any suggestions would be greatly appreciated! How would you solve this? How would you solve this? Any pointers in the right direction? This is happening in both development and production on Ubuntu 20.04.