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

Inherits:
Base
  • Object
show all
Defined in:
lib/rails_admin/config/fields/association.rb

Instance Attribute Summary

Attributes inherited from Base

#defined, #name, #order, #properties

Attributes inherited from Base

#abstract_model, #bindings, #parent, #root

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#association?, #column_css_class, #dom_id, #dom_name, #has_errors?, #initialize, #method_name, #optional, #optional=, #optional?, #type, #virtual?

Methods included from Hideable

#hidden?, #hide, included, #show

Methods inherited from Base

#has_option?, #initialize, register_class_option, #register_deprecated_instance_option, register_deprecated_instance_option, #register_instance_option, register_instance_option, #with

Constructor Details

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

Class Method Details

.inherited(klass) ⇒ Object



9
10
11
# File 'lib/rails_admin/config/fields/association.rb', line 9

def self.inherited(klass)
  super(klass)
end

Instance Method Details

#associated_label_methodObject

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



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

def associated_label_method
  @associated_label_method ||= associated_model_config.object_label_method
end

#associated_model_configObject

Reader for the association’s child model’s configuration



65
66
67
# File 'lib/rails_admin/config/fields/association.rb', line 65

def associated_model_config
  @associated_model_config ||= RailsAdmin.config(association[:child_model])
end

#associationObject

Reader for the association information hash



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

def association
  @properties
end

#child_keyObject

Reader for the association’s child key



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

def child_key
  association[:child_key]
end

#errorsObject

Reader for validation errors of the bound object



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

def errors
  bindings[:object].errors[child_key]
end

#inverse_ofObject

Reader for the inverse relationship



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

def inverse_of
  association[:inverse_of]
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



95
96
97
# File 'lib/rails_admin/config/fields/association.rb', line 95

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