lib/admino/table/presenter.rb in admino-0.0.12 vs lib/admino/table/presenter.rb in admino-0.0.13
- old
+ new
@@ -32,15 +32,25 @@
def initialize(*args)
context = args.pop
collection = args.shift
@collection_klass = args.shift
+
+ if !@collection_klass && !collection.empty?
+ @collection_klass = collection.first.class
+ end
+
@query = args.shift
super(collection, context)
end
def to_html(options = {}, &block)
+
+ if @collection_klass.nil?
+ raise ArgumentError, 'collection is empty and no explicit class is specified'
+ end
+
table_tag(options) do
thead_tag do
thead_tr_tag do
th_tags(&block)
end