Sha256: cb1bd699fdf7db6fd81accda63db8a861d0d04798afc9f996ee069e280533b7d

Contents?: true

Size: 685 Bytes

Versions: 3

Compression:

Stored size: 685 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

      def foreign_key
        options.fetch(:foreign_key, :"#{attribute}_id")
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
semantic-administrate-0.1.1 lib/administrate/field/associative.rb
administrate-0.9.0 lib/administrate/field/associative.rb
semantic-administrate-0.1.0 lib/administrate/field/associative.rb