It explains how to do it for Rails 7 as well as older versions, and even shows a way to handle it without any downtime: How to encrypt existing columns in a Ruby on Rails app with zero downtime