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 inconfig/initializers/spree.rb:
config/initializers/spree.rb
Using the Table in Views
Render the table in your index view using therender_table helper:
app/views/spree/admin/brands/index.html.erb
Table Registration Options
When registering a table, you can specify these options:Column Options
All columns support the following options:The column header label. Can be a symbol (translation key using
Spree.t) or a string.The column type. Determines how the value is rendered.Available types:
string- Plain textnumber- Numeric valuedate- Date formatted withspree_datehelperdatetime- Relative time withspree_time_agohelpermoney- Currency formatted withSpree::Moneystatus- Badge with status-based stylinglink- Clickable link to resourceboolean- Active/inactive badgeimage- Thumbnail imageassociation- Associated record name(s)custom- Custom partial rendering
Whether the column can be shown/hidden by users. Set to
false for filter-only columns.Filter-specific Options
Override the filter input type. Available:
string, number, date, datetime, money, status, boolean, autocomplete, select.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
Custom Partial Options
Column Types Examples
String Column
Link 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:- 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: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:/admin/bulk_operations/new?kind=:action_key&table_key=:table_key.
Bulk Action Options
Icon name from Tabler Icons.
URL for the bulk action endpoint. Use a Lambda for dynamic paths:
action_path: ->(view_context) { view_context.custom_path }.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
Related Documentation
- Admin Navigation - Add custom menu items to the admin
- Extending Admin UI - Inject partials into admin pages
- Search & Filtering - Add searchable/filterable fields
- Customization Quickstart - Overview of all customization options

