spree-resource
Installation
SKILL.md
Adding a Spree Resource
Commands use the Spree CLI (
spree …, Docker, Rails app inserver/). On a classic Rails app without the CLI, runbin/rails g spree:api_resource …from the app root and drop theserver/prefix from paths (seespree-project).
To add a model exposed through the v3 API, use the spree:api_resource generator. One command produces:
- The model (
server/app/models/spree/<name>.rb) and its migration - Store + Admin API controllers and serializers
- A FactoryBot factory and controller specs for both APIs
- Route lines inside the
Spree::Core::Engine.add_routesblock of your app'sconfig/routes.rb - The
read_<plural>/write_<plural>permission scope (Spree.permissions.register_scopeappended toconfig/initializers/spree.rb) and its role-editor label (config/locales/spree_<plural>.en.yml) — Admin surface only
Prerequisite: run spree eject first. Generators execute inside the web container, and only the ejected dev compose bind-mounts ./server, so generated files appear (and persist) on your host.