Class: Administrate::Field::LazyHasMany
- Inherits:
-
HasMany
- Object
- HasMany
- Administrate::Field::LazyHasMany
show all
- Includes:
- LazyHasManyVersion
- Defined in:
- lib/administrate/field/lazy_has_many.rb
Defined Under Namespace
Classes: Engine
Constant Summary
Administrate::Field::LazyHasManyVersion::VERSION
Instance Method Summary
collapse
Instance Method Details
#action ⇒ Object
31
32
33
34
35
|
# File 'lib/administrate/field/lazy_has_many.rb', line 31
def action
raise StandardError.new 'action is missing' if options[:action].blank?
Rails.application.routes.url_helpers.send(options[:action])
end
|
#candidate_resources ⇒ Object
14
15
16
17
18
19
20
21
|
# File 'lib/administrate/field/lazy_has_many.rb', line 14
def candidate_resources
if options.key?(:includes)
includes = options.fetch(:includes)
associated_class.includes(*includes).where(id: data.map(&:id))
else
associated_class.where(id: data.map(&:id))
end
end
|
#custom_attribute_id ⇒ Object
23
24
25
|
# File 'lib/administrate/field/lazy_has_many.rb', line 23
def custom_attribute_id
"#{resource.class.name.underscore}_#{attribute_key}"
end
|
#result_limit ⇒ Object
37
38
39
|
# File 'lib/administrate/field/lazy_has_many.rb', line 37
def result_limit
options[:result_limit] || 10
end
|
#to_s ⇒ Object
27
28
29
|
# File 'lib/administrate/field/lazy_has_many.rb', line 27
def to_s
data.map { |v| display_candidate_resource(v) }
end
|