class Check < ApplicationRecord include RichTextTargetBlank enum :level, %i[A AA AAA] has_rich_text :success_criterion_html scope :search, lambda { |term| joins("INNER JOIN action_text_rich_texts ON action_text_rich_texts.record_id = checks.id AND record_type = 'Check'").where('checks.name LIKE :term OR action_text_rich_texts.body LIKE :term', term: "%#{term}%") } end