A decent rule of thumb I follow: If there's a gem/plugin/package that could do something I want in my product...use it. Don't write the code yourself, unless it actually straight up can't provide the UX or capability you need for your product.
It's hard to argue with a rule of thumb that broad, but I think it's too broad to be useful in practice. You will still always need to make case-by-case decisions at your own discretion, and the rule of thumb will be unnecessary in uncontroversial cases (you probably won't even consider writing your own code to format a number as a string on your website) and will easily be ignored in other cases ("yes, we could just build our homepage and merch page in Squarespace, but we're going to want total control over that entire product so we're going to build it ourselves").