Skip to content

Commit 93a846a

Browse files
committed
Merge pull request activeadmin#4216 from leonelgalan/hash_like_atttribute_table
Allows Hash-like objects to be used in attributes_table
2 parents d787029 + b4264a5 commit 93a846a

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

lib/active_admin/views/components/attributes_table.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class AttributesTable < ActiveAdmin::Component
55
builder_method :attributes_table_for
66

77
def build(obj, *attrs)
8-
@collection = is_array?(obj) ? obj : [obj]
8+
@collection = Array.wrap(obj)
99
@resource_class = @collection.first.class
1010
options = { }
1111
options[:for] = @collection.first if single_record?
@@ -102,10 +102,6 @@ def reflection_for(klass, method)
102102
def single_record?
103103
@single_record ||= @collection.size == 1
104104
end
105-
106-
def is_array?(obj)
107-
obj.respond_to?(:each) && obj.respond_to?(:first) && !obj.is_a?(Hash)
108-
end
109105
end
110106

111107
end

0 commit comments

Comments
 (0)