Class: Administrate::Field::LazyBelongsTo
- Inherits:
-
BelongsTo
- Object
- BelongsTo
- Administrate::Field::LazyBelongsTo
show all
- Includes:
- LazyBelongsToVersion
- Defined in:
- lib/administrate/field/lazy_belongs_to.rb
Defined Under Namespace
Classes: Engine
Constant Summary
Administrate::Field::LazyBelongsToVersion::VERSION
Instance Method Summary
collapse
Instance Method Details
#current_value ⇒ Object
28
29
30
|
# File 'lib/administrate/field/lazy_belongs_to.rb', line 28
def current_value
data ? display_associated_resource : display_placeholder
end
|
#display_placeholder ⇒ Object
22
23
24
25
26
|
# File 'lib/administrate/field/lazy_belongs_to.rb', line 22
def display_placeholder
options.fetch(:placeholder) do
format('Select a %<association>s', association: associated_class.name)
end
end
|
#label_attribute ⇒ Object
40
41
42
|
# File 'lib/administrate/field/lazy_belongs_to.rb', line 40
def label_attribute
options.fetch(:label_attribute) { 'name' }
end
|
#size ⇒ Object
44
45
46
|
# File 'lib/administrate/field/lazy_belongs_to.rb', line 44
def size
options.fetch(:size) { 10 }
end
|
#templated_action ⇒ Object
32
33
34
|
# File 'lib/administrate/field/lazy_belongs_to.rb', line 32
def templated_action
options.fetch(:action).call(self, q: '{q}')
end
|
#to_s ⇒ Object
18
19
20
|
# File 'lib/administrate/field/lazy_belongs_to.rb', line 18
def to_s
data
end
|
#url_helpers ⇒ Object
48
49
50
|
# File 'lib/administrate/field/lazy_belongs_to.rb', line 48
def url_helpers
Rails.application.routes.url_helpers
end
|
#value_attribute ⇒ Object
36
37
38
|
# File 'lib/administrate/field/lazy_belongs_to.rb', line 36
def value_attribute
options.fetch(:value_attribute) { 'id' }
end
|