SanitizeRichText Installation gem 'sanitize_rich_text' Usage class Article < ApplicationRecord sanitize_rich_text :text, elements: %w(h2 h3 p a), attributes: { 'a' => ['href', 'target'] } end