Search code examples
ruby-on-railsrubymodelrails-3.1before-save

Rails way to include functions used in several places


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.