require 'pp' Rails.application.config.to_prepare do Model # Zeitwerk autoload model ModelFile # extend by adding listeners class Model # The 'after_save' macro is now run within the context of the existing Model class. after_commit :run_cli_hooks # Define the new method to be executed on save. def run_cli_hooks # Your custom logic to execute after Model.save or Model.update! goes here. # 📝 Example Logic: puts "\n-------- MODEL --------- #{self.id}\n\n" pp self puts "\n\n" command = "pwd" system(command) end end end