Class: Administrate::Field::Associative
- Inherits:
-
Base
- Object
- Base
- Administrate::Field::Associative
show all
- Defined in:
- lib/administrate/field/associative.rb
Instance Attribute Summary
Attributes inherited from Base
#attribute, #data, #options, #page, #resource
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
associative?, eager_load?, field_type, html_class, #html_class, #initialize, #name, permitted_attribute, #read_value, #required?, searchable?, #to_partial_path, with_options
Class Method Details
.associated_class(resource_class, attr) ⇒ Object
14
15
16
|
# File 'lib/administrate/field/associative.rb', line 14
def self.associated_class(resource_class, attr)
reflection(resource_class, attr).klass
end
|
.associated_class_name(resource_class, attr) ⇒ Object
18
19
20
|
# File 'lib/administrate/field/associative.rb', line 18
def self.associated_class_name(resource_class, attr)
associated_class(resource_class, attr).name
end
|
.association_primary_key_for(resource_class, attr) ⇒ Object
10
11
12
|
# File 'lib/administrate/field/associative.rb', line 10
def self.association_primary_key_for(resource_class, attr)
reflection(resource_class, attr).association_primary_key
end
|
.foreign_key_for(resource_class, attr) ⇒ Object
6
7
8
|
# File 'lib/administrate/field/associative.rb', line 6
def self.foreign_key_for(resource_class, attr)
reflection(resource_class, attr).foreign_key
end
|
.reflection(resource_class, attr) ⇒ Object
22
23
24
|
# File 'lib/administrate/field/associative.rb', line 22
def self.reflection(resource_class, attr)
resource_class.reflect_on_association(attr)
end
|
Instance Method Details
#associated_class ⇒ Object
30
31
32
33
34
35
36
|
# File 'lib/administrate/field/associative.rb', line 30
def associated_class
if option_given?(:class_name)
associated_class_name.constantize
else
self.class.associated_class(resource.class, attribute)
end
end
|
#associated_class_name ⇒ Object
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/administrate/field/associative.rb', line 38
def associated_class_name
if option_given?(:class_name)
deprecated_option(:class_name)
else
self.class.associated_class_name(
resource.class,
attribute
)
end
end
|
#display_associated_resource ⇒ Object
26
27
28
|
# File 'lib/administrate/field/associative.rb', line 26
def display_associated_resource
associated_dashboard.display_resource(data)
end
|
#html_controller ⇒ Object
49
50
51
|
# File 'lib/administrate/field/associative.rb', line 49
def html_controller
"select"
end
|