Class: EacRailsUtils::CommonFormHelper::FormBuilder::AssociationSelectField

Inherits:
Object
  • Object
show all
Defined in:
app/helpers/eac_rails_utils/common_form_helper/form_builder/association_select_field.rb

Instance Method Summary collapse

Instance Method Details

#collectionObject



13
14
15
16
17
# File 'app/helpers/eac_rails_utils/common_form_helper/form_builder/association_select_field.rb', line 13

def collection
  extract_association_key(:collection, *(
      ::Rails.version < '5' ? [:all] : %i[klass all]
    ))
end

#foreign_keyObject



19
20
21
22
23
# File 'app/helpers/eac_rails_utils/common_form_helper/form_builder/association_select_field.rb', line 19

def foreign_key
  extract_association_key(:foreign_key, (
      ::Rails.version < '5' ? :association_foreign_key : :join_foreign_key
    ))
end

#methodsObject



25
26
27
# File 'app/helpers/eac_rails_utils/common_form_helper/form_builder/association_select_field.rb', line 25

def methods
  extract_methods(options)
end

#outputObject



29
30
31
32
33
34
# File 'app/helpers/eac_rails_utils/common_form_helper/form_builder/association_select_field.rb', line 29

def output
  builder.send(:field, field_name, options) do
    builder.form.collection_select(foreign_key, collection, methods[:value], methods[:text],
                                   select_options, class: 'form-control')
  end
end

#select_optionsObject



36
37
38
# File 'app/helpers/eac_rails_utils/common_form_helper/form_builder/association_select_field.rb', line 36

def select_options
  extract_select_options(options)
end