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:
model_class
Class
required
The model class for the table (e.g., Spree::Brand).
search_param
Symbol
default:":name_cont"
The Ransack search parameter for the search box.
search_placeholder
String
Custom placeholder text for the search box.
row_actions
Boolean
default:"false"
Enable row action buttons (edit/delete dropdown).
row_actions_edit
Boolean
default:"true"
Show edit action in row actions dropdown.
row_actions_delete
Boolean
default:"false"
Show delete action in row actions dropdown.
new_resource
Boolean
default:"true"
Show “New Resource” button when collection is empty.
date_range_param
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:
label
Symbol or String
required
The column header label. Can be a symbol (translation key using Spree.t) or a string.
type
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
sortable
Boolean
default:"true"
Whether the column can be sorted.
filterable
Boolean
default:"true"
Whether the column appears in the query builder filter options.
displayable
Boolean
default:"true"
Whether the column can be shown/hidden by users. Set to false for filter-only columns.
default
Boolean
default:"false"
Whether the column is visible by default.
position
Integer
default:"999"
Column order. Lower numbers appear first.
method
Symbol or Lambda
Custom method to extract the column value. Can be a method name or lambda.
align
String
default:"left"
Text alignment: left, center, or right.
width
String
Column width class (e.g., "20" for w-20).
if
Lambda
Conditional visibility. Column only appears if lambda returns true.

Filter-specific Options

filter_type
String
Override the filter input type. Available: string, number, date, datetime, money, status, boolean, autocomplete, select.
ransack_attribute
String
Custom Ransack attribute name for filtering/sorting (defaults to column key).
operators
Array
Available filter operators. Defaults based on column type.
value_options
Array or Lambda
Options for select/status filters. Array of hashes with value and label keys.
search_url
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

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

Custom Partial Options

partial
String
Partial path for custom type columns.
partial_locals
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

label
String
required
Translation key or text for the action button.
icon
String
Icon name from Tabler Icons.
action_path
String | Lambda
required
URL for the bulk action endpoint. Use a Lambda for dynamic paths: action_path: ->(view_context) { view_context.custom_path }.
method
Symbol
default:":put"
HTTP method for the action (:get, :post, :put, :patch, :delete).
position
Integer
default:"999"
Order in the bulk actions menu.
if
Lambda
Conditional visibility based on user permissions.
confirm
String
Confirmation message before executing the action.
button_text
String
Custom text for the modal submit button. Supports translation keys. Defaults to “Confirm”.
button_class
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