Sha256: ecd6536b2e650cc246ddf25f3ffc7d724a3cc27baf97f45b4adb8ff4c950f13a

Contents?: true

Size: 685 Bytes

Versions: 12

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

      def associated_class
        associated_class_name.constantize
      end

      protected

      def associated_dashboard
        "#{associated_class_name}Dashboard".constantize.new
      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

12 entries across 12 versions & 3 rubygems

Version Path
viniBaxterDesk-22.0.0 lib/administrate/field/associative.rb
viniBaxterDesk-0.21.0 lib/administrate/field/associative.rb
viniBaxterDesk-0.20.0 lib/administrate/field/associative.rb
viniBaxterDesk-0.14.0 lib/administrate/field/associative.rb
viniBaxterDesk-0.13.2 lib/administrate/field/associative.rb
viniBaxterDesk-0.13.1 lib/administrate/field/associative.rb
administrate-0.13.0 lib/administrate/field/associative.rb
administrate-0.12.0 lib/administrate/field/associative.rb
administrate-0.11.0 lib/administrate/field/associative.rb
semantic-administrate-0.10.1 lib/administrate/field/associative.rb
semantic-administrate-0.10.0 lib/administrate/field/associative.rb
administrate-0.10.0 lib/administrate/field/associative.rb