class Option < ActiveRecord::Base
  include AuthoredModel
  include SanitizableAttributes

  attr_accessible :role, :title, :description, :required

  def to_s
    title
  end

  scope :options_for, lambda { |role| where(:role => role) }
  scope :ordered_by_title_desc, order("#{table_name}.title DESC")

  is_versioned_ext

  sanitize_attributes :description

  def display_name
    title
  end

  def self.db_search(q)
    q = "%#{q}%"
    t = arel_table
    where(t[:role].matches(q))
  end

  ROLES = [
    "asset_type",
    "audit_duration",
    "audit_frequency",
    # "control_type",
    "control_kind",
    "control_means",
    "document_status",
    "document_type",
    "document_year",
    "entity_kind",
    "entity_type",
    "language",
    "facility_kind",
    "facility_type",
    "network_zone",
    "person_language",
    "product_kind",
    "product_type",
    #"directive_kind",
    "reference_type",
    "request_type",
    # "system_type",
    "system_kind",
    "threat_type",
    "verify_frequency",
    "verify_frequency"
  ]
end

class Option < ActiveRecord::Base
  include AuthoredModel
  include SanitizableAttributes

  attr_accessible :role, :title, :description, :required

  def to_s
    title
  end

  scope :options_for, lambda { |role| where(:role => role) }
  scope :ordered_by_title_desc, order("#{table_name}.title DESC")

  is_versioned_ext

  sanitize_attributes :description

  def display_name
    title
  end

  def self.db_search(q)
    q = "%#{q}%"
    t = arel_table
    where(t[:role].matches(q))
  end

  ROLES = [
    "asset_type",
    "audit_duration",
    "audit_frequency",
    # "control_type",
    "control_kind",
    "control_means",
    "document_status",
    "document_type",
    "document_year",
    "entity_kind",
    "entity_type",
    "language",
    "facility_kind",
    "facility_type",
    "network_zone",
    "person_language",
    "product_kind",
    "product_type",
    #"directive_kind",
    "reference_type",
    "request_type",
    # "system_type",
    "system_kind",
    "threat_type",
    "verify_frequency"
  ]
end

Remove duplicate 'verify_frequency' from Option::ROLES
Remove duplicate 'verify_frequency' from Option::ROLES [story:41797815]
