`display_name_method_for` works not as intended with Draper

Author: faucctCreated Jan 21, 2016Updated Mar 4, 2026
Labelsbughelp wanted

This is the breadcrumb I get while using Draper decorator with delegate_all option: 2016-01-21 14 01 40 ActiveAdmin can not look up the display method name correctly here:

ruby
      def display_name_method_for(resource)
        @@display_name_methods_cache ||= {}
        @@display_name_methods_cache[resource.class] ||= begin
          methods = active_admin_application.display_name_methods - association_methods_for(resource)
          method  = methods.detect{ |method| resource.respond_to? method }

          if method != :to_s || resource.method(method).source_location
            method
          else
            DISPLAY_NAME_FALLBACK
          end
        end
      end

My decorator instance does not respond to any other than to_s methods, as the model does. In this case it is supposed to use the fallback, but the problem is that decorator to_s method got a source location: ["~/.rvm/gems/ruby-2.1.5/gems/draper-2.1.0/lib/draper/delegation.rb", 10].