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

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

Attributes included from Proxyable

#bindings

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#association?, #editable?, #errors, #html_default_value, #initialize, #inspect, #method_name, #optional, #optional=, #optional?, #type, #type_css_class

Methods included from Groupable

#group

Methods included from Hideable

#hidden?, #hide, included, #show

Methods included from Configurable

#has_option?, included, #register_deprecated_instance_option, #register_instance_option

Methods included from Proxyable

#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_model_configObject

Reader for the association’s child model’s configuration



58
59
60
# File 'lib/rails_admin/config/fields/association.rb', line 58

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

#associated_object_label_methodObject

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



63
64
65
# File 'lib/rails_admin/config/fields/association.rb', line 63

def associated_object_label_method
  @associated_object_label_method ||= associated_model_config.object_label_method
end

#associated_primary_keyObject

Reader for associated primary key



68
69
70
# File 'lib/rails_admin/config/fields/association.rb', line 68

def associated_primary_key
  @associated_primary_key ||= association[:primary_key_proc].call
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

#foreign_keyObject

Reader for the association’s key



73
74
75
# File 'lib/rails_admin/config/fields/association.rb', line 73

def foreign_key
  association[:foreign_key]
end

#inverse_ofObject

Reader for the inverse relationship



78
79
80
# File 'lib/rails_admin/config/fields/association.rb', line 78

def inverse_of
  association[:inverse_of]
end

#multiple?Boolean

has many?

Returns:

  • (Boolean)


98
99
100
# File 'lib/rails_admin/config/fields/association.rb', line 98

def multiple?
  true
end

#polymorphic?Boolean

Reader whether this is a polymorphic association

Returns:

  • (Boolean)


83
84
85
# File 'lib/rails_admin/config/fields/association.rb', line 83

def polymorphic?
  association[:polymorphic]
end

#valueObject

Reader for the association’s value unformatted



93
94
95
# File 'lib/rails_admin/config/fields/association.rb', line 93

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

#virtual?Boolean

Returns:

  • (Boolean)


102
103
104
# File 'lib/rails_admin/config/fields/association.rb', line 102

def virtual?
  true
end