The lib/ folder should always be a last resort. It's primarily reserved for monkey patches and custom modifications to libraries you're using all through out your application. Generally speaking, if you're sticking your own code in here you're doing something wrong.

In addition, this method has no namespacing/module around it and because of where this file is at it's effectively a global method available throughout your entire application despite the fact that it's only used one place in one model (excluding your test).

Rather than polluting the global namespace with this method and scattering the functionality your model needs around, this needs to be moved into a private method in the model its actually used in.