Skip to main content
Spree Admin provides a flexible table system for displaying resource listings with customizable columns, sorting, filtering, and bulk actions. The Tables DSL allows you to define table configurations for your resources and extend existing ones.
The Tables system uses a declarative API accessible via Spree.admin.tables. This allows you to programmatically add, modify, and remove table columns and bulk actions directly in your initializers.

Basic Usage

Creating a New Table

Register a new table for your resource in config/initializers/spree.rb:
config/initializers/spree.rb

Using the Table in Views

Render the table in your index view using the render_table helper:
app/views/spree/admin/brands/index.html.erb
With additional options:

Table Registration Options

When registering a table, you can specify these options:
Class
required
The model class for the table (e.g., Spree::Brand).
Symbol
default:":name_cont"
The Ransack search parameter for the search box.
String
Custom placeholder text for the search box.
Boolean
default:"false"
Enable row action buttons (edit/delete dropdown).
Boolean
default:"true"
Show edit action in row actions dropdown.
Boolean
default:"false"
Show delete action in row actions dropdown.
Boolean
default:"true"
Show “New Resource” button when collection is empty.
Symbol
Enable date range filter for the specified column (e.g., :created_at).
Action for link columns (:edit or :show).

Column Options

All columns support the following options:
Symbol or String
required
The column header label. Can be a symbol (translation key using Spree.t) or a string.
String
default:"string"
The column type. Determines how the value is rendered.Available types:
  • string - Plain text
  • number - Numeric value
  • date - Date formatted with spree_date helper
  • datetime - Relative time with spree_time_ago helper
  • money - Currency formatted with Spree::Money
  • status - Badge with status-based styling
  • link - Clickable link to resource
  • boolean - Active/inactive badge
  • image - Thumbnail image
  • association - Associated record name(s)
  • custom - Custom partial rendering
Boolean
default:"true"
Whether the column can be sorted.
Boolean
default:"true"
Whether the column appears in the query builder filter options.
Boolean
default:"true"
Whether the column can be shown/hidden by users. Set to false for filter-only columns.
Boolean
default:"false"
Whether the column is visible by default.
Integer
default:"999"
Column order. Lower numbers appear first.
Symbol or Lambda
Custom method to extract the column value. Can be a method name or lambda.
String
default:"left"
Text alignment: left, center, or right.
String
Column width class (e.g., "20" for w-20).
Lambda
Conditional visibility. Column only appears if lambda returns true.

Filter-specific Options

String
Override the filter input type. Available: string, number, date, datetime, money, status, boolean, autocomplete, select.
String
Custom Ransack attribute name for filtering/sorting (defaults to column key).
Array
Available filter operators. Defaults based on column type.
Array or Lambda
Options for select/status filters. Array of hashes with value and label keys.
String | Lambda
URL for autocomplete filter type. Use a Lambda for dynamic paths: search_url: ->(view_context) { view_context.spree.admin_taxons_select_options_path(format: :json) }.

Custom Sort Options

Symbol
Custom scope name for ascending sort (bypasses Ransack).
Symbol
Custom scope name for descending sort (bypasses Ransack).

Custom Partial Options

String
Partial path for custom type columns.
Hash or Lambda
Additional locals to pass to the partial. Lambda receives the record.

Column Types Examples

String Column

Links to the resource edit or show page:

Money Column

Displays formatted currency:

Status Column

Displays a colored badge based on the status value:
Status values are automatically styled:
  • Green (badge-active): active, complete, completed, paid, shipped, available
  • Yellow (badge-warning): draft, pending, processing, ready
  • Gray (badge-inactive): archived, canceled, cancelled, failed, void, inactive

Boolean Column

DateTime Column

Displays relative time (e.g., “2 hours ago”):

Association Column

For displaying related records:

Custom Partial Column

For complex rendering:
The partial receives record, column, and value locals plus any custom locals.

Filter-only Column

Columns that can be filtered but not displayed:

Modifying Existing Tables

Adding Columns to Existing Tables

config/initializers/spree.rb

Updating Existing Columns

Removing Columns

Inserting Columns at Specific Positions

Bulk Actions

Add bulk actions that appear when users select multiple rows:
The modal is automatically rendered via /admin/bulk_operations/new?kind=:action_key&table_key=:table_key.

Bulk Action Options

String
required
Translation key or text for the action button.
String
Icon name from Tabler Icons.
String | Lambda
required
URL for the bulk action endpoint. Use a Lambda for dynamic paths: action_path: ->(view_context) { view_context.custom_path }.
Symbol
default:":put"
HTTP method for the action (:get, :post, :put, :patch, :delete).
Integer
default:"999"
Order in the bulk actions menu.
Lambda
Conditional visibility based on user permissions.
String
Confirmation message before executing the action.
String
Custom text for the modal submit button. Supports translation keys. Defaults to “Confirm”.
String
default:"btn-primary"
CSS class for the modal submit button (e.g., btn-danger for destructive actions).

Managing Bulk Actions

Custom Sorting

For columns that need custom database queries:

Available Tables

Spree registers tables for all built-in resources:

API Reference

Table Methods

Registry Methods