Sha256: 48dfb5f16091767f9905941b27ec44724ddfd24d8feeb4ba1aa4cecd5c43aeac
Contents?: true
Size: 815 Bytes
Versions: 2
Compression:
Stored size: 815 Bytes
Contents
require_relative "associative" module Administrate module Field class BelongsTo < Associative def self.permitted_attribute(attr, _options = nil) :"#{attr}_id" end def permitted_attribute foreign_key end def associated_resource_options [nil] + candidate_resources.map do |resource| [display_candidate_resource(resource), resource.send(primary_key)] end end def selected_option data && data.send(primary_key) end private def candidate_resources order = options.delete(:order) order ? associated_class.order(order) : associated_class.all end def display_candidate_resource(resource) associated_dashboard.display_resource(resource) end end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
semantic-administrate-0.1.1 | lib/administrate/field/belongs_to.rb |
administrate-0.9.0 | lib/administrate/field/belongs_to.rb |