Sha256: bd82f14b7289c08955b81ede47ae34ee9caa62f8e915dc55317e5eb27d150df8
Contents?: true
Size: 612 Bytes
Versions: 4
Compression:
Stored size: 612 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": []} 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
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
madmin-2.0.0 | lib/madmin/fields/has_many.rb |
madmin-1.2.11 | lib/madmin/fields/has_many.rb |
madmin-1.2.10 | lib/madmin/fields/has_many.rb |
madmin-1.2.9 | lib/madmin/fields/has_many.rb |