Sha256: 8ac9626d680a082f27bb8413ebb652121e7a2654d06db139d1c533cd0f4faaf9
Contents?: true
Size: 621 Bytes
Versions: 8
Compression:
Stored size: 621 Bytes
Contents
module Madmin module Fields class HasMany < Field def options_for_select(record) if (records = record.send(attribute_name)) return [] unless records.first resource = Madmin.resource_for(records.first) records.map { |record| [resource.display_name(record), record.id] } else [] end end def to_param {"#{attribute_name.to_s.singularize}_ids".to_sym => []} end def index_path Madmin.resource_by_name(model.reflect_on_association(attribute_name).klass).index_path(format: :json) end end end end
Version data entries
8 entries across 8 versions & 1 rubygems