Step 1: Add Attachment to the Model
First, let’s add a logo attachment to the Brand model:app/models/spree/brand.rb
Step 2: Permit the Attachment Attribute
For the admin form to accept the file upload, we need to permit thelogo attribute in the controller.
Update your brands controller:
app/controllers/spree/admin/brands_controller.rb
Step 3: Add File Upload Field to the Admin Form
Now let’s add the file upload field to the brand form. Spree provides aspree_file_field helper that handles everything including:
- Drag and drop upload
- Image preview
- Direct upload to storage
- Optional image cropping
app/views/spree/admin/brands/_form.html.erb
Add cropping functionality
To enable cropping functionality, add thecrop: true option to the spree_file_field helper.
Step 4: Display the Logo in the Index Table
Let’s show a thumbnail of the brand logo in the admin index view. Update the table header partial:app/views/spree/admin/brands/_table_header.html.erb
app/views/spree/admin/brands/_table_row.html.erb

