Class: Pwb::FieldKey

Inherits:
ApplicationRecord show all
Defined in:
app/models/pwb/field_key.rb

Overview

A FieldKey records the translation key that is used by a field such as propType

Class Method Summary collapse

Class Method Details

.get_options_by_tag(tag) ⇒ Object

below is used to get values to populate dropdowns in search forms



20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/models/pwb/field_key.rb', line 20

def self.get_options_by_tag(tag)
  options = []
  translation_keys = FieldKey.where(tag: tag).visible.pluck("global_key")

  translation_keys.each do |option_key|
    option = OpenStruct.new
    option.value = option_key
    option.label = I18n.t option_key
    options.push option
  end
  options.sort_by { |r| r.label.downcase }
end