r/ruby • • Apr 10 '21

💎Ruby tip: Make your own callbacks using ActiveSupport::Callbacks

Do you know about the callbacks available in Rails controllers, models, mailboxes, action cable, middleware, etc? It's all using ActiveSupport's Callbacks module to do that. Well, you can make your own callbacks with it too!

Rough example on how to use the module

More complex, real-world example: StimulusReflex callbacks PR

31 Upvotes

Duplicates