2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
# File 'lib/admin_widgets/extensions/simple_form_ext.rb', line 2
def detect_common_display_methods
collection_classes = detect_collection_classes
if collection_classes.include?(Array)
{ :label => :first, :value => :second }
elsif collection_includes_basic_objects?(collection_classes)
{ :label => :to_s, :value => :to_s }
else
sample = collection.first || collection.last
{ :label => SimpleForm.collection_label_methods.find { |m| sample.respond_to?(m) },
:value => SimpleForm.collection_value_methods.find { |m| sample.respond_to?(m) } }
end
end
|