With the GDPR just around the corner, here are two useful ways to protect your users' IP addresses.
Both support IPv4 and IPv6, and are included in the ip_anonymizer gem.
This transforms IP addresses with a keyed hash function (PBKDF2-HMAC-SHA256). If an unkeyed function is used (like SHA1), it's trivial to build a rainbow table.