Sha256: a21ea8decacf39c837636ebb0966234f2af4f3f41d59bb2c9cf0b788cf4ffe07
Contents?: true
Size: 821 Bytes
Versions: 3
Compression:
Stored size: 821 Bytes
Contents
require_relative "base" require "administrate/pages/table" module Administrate module Field class HasMany < Field::Base def associated_table Administrate::Page::Table.new(associated_dashboard) end def self.permitted_attribute(attribute) { "#{attribute.to_s.singularize}_ids".to_sym => [] } end def permitted_attribute self.class.permitted_attribute(attribute) end def attribute_key permitted_attribute.keys.first end def candidate_records Object.const_get(resource_class_name).all end private def associated_dashboard Object.const_get("#{resource_class_name}Dashboard").new end def resource_class_name attribute.to_s.singularize.camelcase end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
administrate-0.0.4 | lib/administrate/fields/has_many.rb |
administrate-0.0.3 | lib/administrate/fields/has_many.rb |
administrate-0.0.2 | lib/administrate/fields/has_many.rb |