Class: ActiveAdmin::Views::IndexAsGrid
- Defined in:
- lib/active_admin/views/index_as_grid.rb
Overview
# Index as a Grid
Sometimes you want to display the index screen for a set of resources as a grid (possibly a grid of thumbnail images). To do so, use the :grid option for the index block.
“‘ruby index as: :grid do |product|
link_to image_tag(product.image_path), admin_product_path(product)
end “‘
The block is rendered within a cell in the grid once for each resource in the collection. The resource is passed into the block for you to use in the view.
You can customize the number of columns that are rendered using the columns option:
“‘ruby index as: :grid, columns: 5 do |product|
link_to image_tag(product.image_path), admin_product_path(product)
end “‘
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.index_name ⇒ Object
42 43 44 |
# File 'lib/active_admin/views/index_as_grid.rb', line 42 def self.index_name "grid" end |
Instance Method Details
#build(page_presenter, collection) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/active_admin/views/index_as_grid.rb', line 31 def build(page_presenter, collection) @page_presenter = page_presenter @collection = collection.to_a add_class "index" build_table end |
#number_of_columns ⇒ Object
38 39 40 |
# File 'lib/active_admin/views/index_as_grid.rb', line 38 def number_of_columns @page_presenter[:columns] || default_number_of_columns end |