wip: initializer

This commit is contained in:
Leon van Kammen 2025-10-29 15:05:18 +01:00
parent e904c0733b
commit 0913b8eab9

View file

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