Class: Administrate::Field::BelongsTo
- Inherits:
-
Associative
- Object
- Base
- Associative
- Administrate::Field::BelongsTo
- Defined in:
- lib/administrate/field/belongs_to.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Base
#attribute, #data, #page, #resource
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Associative
#associated_class, #display_associated_resource
Methods inherited from Base
#html_class, html_class, #initialize, #name, searchable?, #to_partial_path, with_options
Constructor Details
This class inherits a constructor from Administrate::Field::Base
Class Method Details
.permitted_attribute(attr, _options = nil) ⇒ Object
6 7 8 |
# File 'lib/administrate/field/belongs_to.rb', line 6 def self.permitted_attribute(attr, = nil) :"#{attr}_id" end |
Instance Method Details
#associated_resource_options ⇒ Object
14 15 16 17 18 |
# File 'lib/administrate/field/belongs_to.rb', line 14 def [nil] + candidate_resources.map do |resource| [display_candidate_resource(resource), resource.send(primary_key)] end end |
#permitted_attribute ⇒ Object
10 11 12 |
# File 'lib/administrate/field/belongs_to.rb', line 10 def permitted_attribute foreign_key end |
#selected_option ⇒ Object
20 21 22 |
# File 'lib/administrate/field/belongs_to.rb', line 20 def selected_option data && data.send(primary_key) end |