Class: Administrate::Field::BelongsTo
Instance Attribute Summary
Attributes inherited from Base
#attribute, #data, #options, #page, #resource
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Associative
associated_class, #associated_class, #associated_class_name, associated_class_name, association_primary_key_for, #display_associated_resource, foreign_key_for, #html_controller, reflection
Methods inherited from Base
associative?, field_type, html_class, #html_class, #html_controller, #initialize, local_partial_prefixes, #name, partial_prefixes, #partial_prefixes, #read_value, #required?, searchable?, sortable?, with_options
Class Method Details
.eager_load? ⇒ Boolean
11
12
13
|
# File 'lib/administrate/field/belongs_to.rb', line 11
def self.eager_load?
true
end
|
.permitted_attribute(attr, options = {}) ⇒ Object
6
7
8
9
|
# File 'lib/administrate/field/belongs_to.rb', line 6
def self.permitted_attribute(attr, options = {})
resource_class = options[:resource_class]
foreign_key_for(resource_class, attr)
end
|
Instance Method Details
#associated_resource_options ⇒ Object
19
20
21
22
23
24
25
26
|
# File 'lib/administrate/field/belongs_to.rb', line 19
def associated_resource_options
candidate_resources.map do |resource|
[
display_candidate_resource(resource),
resource.send(association_primary_key)
]
end
end
|
#include_blank_option ⇒ Object
32
33
34
|
# File 'lib/administrate/field/belongs_to.rb', line 32
def include_blank_option
options.fetch(:include_blank, true)
end
|
#permitted_attribute ⇒ Object
15
16
17
|
# File 'lib/administrate/field/belongs_to.rb', line 15
def permitted_attribute
foreign_key
end
|
#selected_option ⇒ Object
28
29
30
|
# File 'lib/administrate/field/belongs_to.rb', line 28
def selected_option
data&.send(association_primary_key)
end
|