Class: RailsAdmin::Config::Fields::Association

Inherits:
Base
  • Object
show all
Defined in:
lib/rails_admin/config/fields/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 Base

#association?, #editable?, #errors, #form_default_value, #form_value, #generic_field_help, #generic_help, #initialize, #inverse_of, #method_name, #optional, #optional=, #optional?, #parse_input, #parse_value, #type, #type_css_class

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

#associated_model_configObject

Reader for the association's child model's configuration


70
71
72
# File 'lib/rails_admin/config/fields/association.rb', line 70

def associated_model_config
  @associated_model_config ||= RailsAdmin.config(association.klass)
end

#associated_model_limitObject


113
114
115
# File 'lib/rails_admin/config/fields/association.rb', line 113

def associated_model_limit
  RailsAdmin.config.default_associated_collection_limit
end

#associated_object_label_methodObject

Reader for the association's child model object's label method


75
76
77
# File 'lib/rails_admin/config/fields/association.rb', line 75

def associated_object_label_method
  @associated_object_label_method ||= associated_model_config.object_label_method
end

#associated_primary_keyObject

Reader for associated primary key


80
81
82
# File 'lib/rails_admin/config/fields/association.rb', line 80

def associated_primary_key
  @associated_primary_key ||= associated_model_config.abstract_model.primary_key
end

#associationObject

Reader for the association information hash


13
14
15
# File 'lib/rails_admin/config/fields/association.rb', line 13

def association
  @properties
end

#foreign_keyObject

Reader for the association's key


85
86
87
# File 'lib/rails_admin/config/fields/association.rb', line 85

def foreign_key
  association.foreign_key
end

#multiple?Boolean

has many?

Returns:

  • (Boolean)

105
106
107
# File 'lib/rails_admin/config/fields/association.rb', line 105

def multiple?
  true
end

#polymorphic?Boolean

Reader whether this is a polymorphic association

Returns:

  • (Boolean)

90
91
92
# File 'lib/rails_admin/config/fields/association.rb', line 90

def polymorphic?
  association.polymorphic?
end

#valueObject

Reader for the association's value unformatted


100
101
102
# File 'lib/rails_admin/config/fields/association.rb', line 100

def value
  bindings[:object].send(association.name)
end

#virtual?Boolean

Returns:

  • (Boolean)

109
110
111
# File 'lib/rails_admin/config/fields/association.rb', line 109

def virtual?
  true
end