How to sanitize sql fragment in Rails May 26, 2023 by Tarik You can just use: ActiveRecord::Base::sanitize_sql(string)