https://ash-hq.org/docs/guides/ash/latest/tutorials/get-started proposes this file structure:
lib/
├─ helpdesk/
│ ├─ support/
│ │ ├─ registry.ex # <-----
│ │ ├─ resources/
│ │ │ ├─ ticket.ex
│ ├─ support.ex
support
is the API here or is it helpdesk
? I am struggling with the wording. Anyhow I understand the tutorial so that the file registry.ex
has always to be under the `support´ directory.
This works
My project has this file structure:
lib
├── feriendaten
│ ├── geo
│ │ ├── geo.ex
│ │ └── resources
│ │ ├── level.ex
│ │ ├── location.ex
│ │ └── school.ex
│ ├── legacy
│ │ ├── legacy.ex
│ │ └── resources
│ │ └── legacy_location.ex
│ ├── registry.ex # <---- one file
The file lib/feriendaten/registry.ex
has this content:
defmodule Feriendaten.Registry do
use Ash.Registry,
extensions: [
# This extension adds helpful compile time validations
Ash.Registry.ResourceValidations
]
entries do
entry Feriendaten.Geo.Level
entry Feriendaten.Geo.Location
entry Feriendaten.Legacy.LegacyLocation
entry Feriendaten.Geo.School
end
end
That works without a problem.
This doesn't works
According to the above tutorial the file structure should be like this (one registry.ex
in each directory):
lib
├── feriendaten
│ ├── geo
│ │ ├── geo.ex
│ │ ├── registry.ex # <- first registry.ex
│ │ └── resources
│ │ ├── level.ex
│ │ ├── location.ex
│ │ └── school.ex
│ ├── legacy
│ │ ├── legacy.ex
│ │ ├── registry.ex # <- second registry.ex
│ │ └── resources
│ │ └── legacy_location.ex
I tried it with this code:
lib/feriendaten/geo/registry.ex
defmodule Feriendaten.Geo.Registry do
use Ash.Registry,
extensions: [
# This extension adds helpful compile time validations
Ash.Registry.ResourceValidations
]
entries do
entry Feriendaten.Geo.Level
entry Feriendaten.Geo.Location
entry Feriendaten.Geo.School
end
end
lib/feriendaten/legacy/registry.ex
defmodule Feriendaten.Legacy.Registry do
use Ash.Registry,
extensions: [
# This extension adds helpful compile time validations
Ash.Registry.ResourceValidations
]
entries do
entry Feriendaten.Legacy.LegacyLocation
end
end
But this results into this error:
Compiling 4 files (.ex)
** (EXIT from #PID<0.95.0>) an exception was raised:
** (RuntimeError) Resources Feriendaten.Geo.Location, Feriendaten.Geo.Level must be included in the registry.
Is the file path of the registry.ex
in the tutorial misleading or am I doing a mistake? How can I fix it?