Class: RailsAdmin::Config::Fields::Types::CompositeKeysBelongsToAssociation

Inherits:
BelongsToAssociation show all
Defined in:
lib/rails_admin/config/fields/types/composite_keys_belongs_to_association.rb

Constant Summary

Constants inherited from Base

Base::NAMED_INSTANCE_VARIABLES

Instance Attribute Summary

Attributes inherited from Base

#abstract_model, #defined, #name, #order, #parent, #properties, #root, #section

Instance Method Summary collapse

Methods inherited from BelongsToAssociation

#method_name, #multiple?

Methods inherited from Association

#associated_model_config, #associated_model_limit, #associated_object_label_method, #associated_prepopulate_params, #associated_primary_key, #association, #dynamic_scope_relationships, #method_name, #multiple?, #polymorphic?, #value, #virtual?

Methods inherited from Base

#association?, #eager_load_values, #editable?, #errors, #filter_options, #form_default_value, #form_value, #generic_field_help, #generic_help, #initialize, #inverse_of, #method_name, #optional, #optional=, #optional?, #parse_value, #sort_column, #type, #type_css_class, #value, #virtual?

Methods included from Inspectable

#inspect

Methods included from Groupable

#group

Methods included from Hideable

#hidden?, #hide, included, #show

Methods included from Configurable

#has_option?, #register_deprecated_instance_option, #register_instance_option

Methods included from Proxyable

#bindings, #bindings=, #with

Constructor Details

This class inherits a constructor from RailsAdmin::Config::Fields::Base

Instance Method Details

#parse_input(params) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/rails_admin/config/fields/types/composite_keys_belongs_to_association.rb', line 20

def parse_input(params)
  return unless params[method_name].present? && association.foreign_key.is_a?(Array) && !nested_form

  association.foreign_key.zip(CompositePrimaryKeys::CompositeKeys.parse(params.delete(method_name))).each do |key, value|
    params[key] = value
  end
end

#selected_idObject



16
17
18
# File 'lib/rails_admin/config/fields/types/composite_keys_belongs_to_association.rb', line 16

def selected_id
  association.foreign_key.map { |attribute| bindings[:object].safe_send(attribute) }.to_composite_keys.to_s
end