Sha256: 9228522082fe2b65c19527ecc6da018f2d1383137caa5b426218b6bc9a184cde

Contents?: true

Size: 596 Bytes

Versions: 6

Compression:

Stored size: 596 Bytes

Contents

require_relative "base"

module Administrate
  module Field
    class Associative < Base
      def display_associated_resource
        associated_dashboard.display_resource(data)
      end

      protected

      def associated_dashboard
        "#{associated_class_name}Dashboard".constantize.new
      end

      def associated_class
        associated_class_name.constantize
      end

      def associated_class_name
        options.fetch(:class_name, attribute.to_s.singularize.camelcase)
      end

      def primary_key
        options.fetch(:primary_key, :id)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
administrate-0.8.1 lib/administrate/field/associative.rb
administrate-0.8.0 lib/administrate/field/associative.rb
administrate-0.7.0 lib/administrate/field/associative.rb
administrate-0.6.0 lib/administrate/field/associative.rb
administrate-0.5.0 lib/administrate/field/associative.rb
administrate-0.4.0 lib/administrate/field/associative.rb