Rails way to include functions used in several places
-
06-04-2021 - |
Question
I have a function (creation of a record in a table) that must be executed within before_save routines of models. What is the preferred way to do it? I am in Rails 3.1. A module in lib? A class in lib? application.rb?
Any example?
Thanks
Solution
Module in lib/
. Why a class if it's just a function? And don't clutter application.rb
.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow