README.md in dining-table-1.0.0 vs README.md in dining-table-1.1.0
- old
+ new
@@ -93,20 +93,29 @@
column :stock, footer: lambda { "Total: #{ collection.sum(&:stock) }" }
end
end
```
-Please note how the collection passed in when creating the table obect (`@cars` in `CarTable.new(@cars, self)`) is available as `collection`.
+Please note how the collection passed in when creating the table object (`@cars` in `CarTable.new(@cars, self)`) is available as `collection`.
Similarly to `skip_header`, if for some reason you don't want a footer (even though at least one column defines one), call `skip_footer`:
```ruby
class CarTable < DiningTable::Table
def define
skip_footer
column :brand, footer: 'Footer'
end
end
+```
+#### Empty collection
+
+Note that when the collection to be presented in the table is empty, `dining-table` can't determine table headers
+that aren't explicitly specified as there are no objects to use with `human_attribute_name`. In order to avoid this
+edge case, you can pass in the class of the objects normally present in the collection when creating the table:
+
+```ruby
+<%= CarTable.new(@cars, self, class: Car).render %>
```
### Links and view helpers
When rendering the table in a view using `<%= CarTable.new(@cars, self).render %>`, the `self` parameter is the view context. It is made available through the `h`