Sha256: c471255813c59e24b4e08f8200692b39d9c92e6a96ca31ab38ccfcc3a17247fe

Contents?: true

Size: 710 Bytes

Versions: 2

Compression:

Stored size: 710 Bytes

Contents

require 'administrate/field/belongs_to'
require 'administrate/field/scoped_belongs_to/version'
require 'rails/engine'

module Administrate
  module Field
    class ScopedBelongsTo < Administrate::Field::BelongsTo
      include ScopedBelongsToVersion

      class Engine < ::Rails::Engine
      end

      def to_s
        data
      end

      def to_partial_path
        "/fields/#{self.class.superclass.field_type}/#{page}"
      end

      private

      def candidate_resources
        scope = options[:scope] ? options[:scope].call(self) : associated_class.all

        order = options.delete(:order)
        order ? scope.reorder(order) : scope
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
administrate-field-scoped_belongs_to-0.2.1 lib/administrate/field/scoped_belongs_to.rb
administrate-field-scoped_belongs_to-0.2.0 lib/administrate/field/scoped_belongs_to.rb