Class: Administrate::Field::Polymorphic
- Inherits:
-
BelongsTo
- Object
- Base
- Associative
- BelongsTo
- Administrate::Field::Polymorphic
- Defined in:
- lib/administrate/field/polymorphic.rb
Instance Attribute Summary
Attributes inherited from Base
#attribute, #data, #options, #page, #resource
Class Method Summary collapse
Instance Method Summary collapse
- #associated_resource_grouped_options ⇒ Object
- #permitted_attribute ⇒ Object
- #selected_global_id ⇒ Object
Methods inherited from BelongsTo
#associated_resource_options, eager_load?, #include_blank_option, #selected_option
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?, eager_load?, field_type, html_class, #html_class, #html_controller, #initialize, #name, #read_value, #required?, searchable?, #to_partial_path, with_options
Constructor Details
This class inherits a constructor from Administrate::Field::Base
Class Method Details
.permitted_attribute(attr, _options = {}) ⇒ Object
6 7 8 |
# File 'lib/administrate/field/polymorphic.rb', line 6 def self.permitted_attribute(attr, = {}) {attr => %i[type value]} end |
Instance Method Details
#associated_resource_grouped_options ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/administrate/field/polymorphic.rb', line 10 def classes.map do |klass| [klass.to_s, candidate_resources_for(klass).map do |resource| [display_candidate_resource(resource), resource.to_global_id] end] end end |
#permitted_attribute ⇒ Object
18 19 20 |
# File 'lib/administrate/field/polymorphic.rb', line 18 def permitted_attribute {attribute => %i[type value]} end |
#selected_global_id ⇒ Object
22 23 24 |
# File 'lib/administrate/field/polymorphic.rb', line 22 def selected_global_id data&.to_global_id end |