lib/administrate/fields/belongs_to.rb in administrate-0.1.0 vs lib/administrate/fields/belongs_to.rb in administrate-0.1.1

- old
+ new

@@ -1,25 +1,31 @@ -require_relative "base" +require_relative "associative" module Administrate module Field - class BelongsTo < Field::Base + class BelongsTo < Associative def self.permitted_attribute(attr) :"#{attr}_id" end def permitted_attribute self.class.permitted_attribute(attribute) end - def candidate_records - Object.const_get(associated_class_name).all + def associated_resource_options + candidate_resources.map do |resource| + [display_candidate_resource(resource), resource.id] + end end private - def associated_class_name - options.fetch(:class_name, attribute.to_s.camelcase) + def candidate_resources + associated_class.all + end + + def display_candidate_resource(resource) + associated_dashboard.display_resource(resource) end end end end