MeAndMark
Where is the config function for an Ash Domain created?
I am starting a project with Ash and Phoenix. I take the general steps shown in the Get Started with Ash and Phoenix tutorial on the Ash documentation website. I create an Ash domain and resources. I set up the repo for the project. I add the Ash domains to the config.exs file.
config :forum_app,
ash_domains: [ForumApp.Forum],
ecto_repos: [ForumApp.Repo],
generators: [timestamp_type: :utc_datetime]
When I run the mix ash.codegen command to create the initial database migration. I get the following error message in the Terminal:
(UndefinedFunctionError) function ForumApp.Forum.config/0 is undefined or private
(forum_app 0.1.0) ForumApp.Forum.config()
(ash_postgres 2.4.12) lib/migration_generator/migration_generator.ex:160: AshPostgres.MigrationGenerator.snapshot_path/2
(ash_postgres 2.4.12) lib/migration_generator/migration_generator.ex:168: anonymous fn/2 in AshPostgres.MigrationGenerator.create_extension_migrations/2
(elixir 1.17.2) lib/enum.ex:1703: Enum."-map/2-lists^map/1-1-"/2
(elixir 1.17.2) lib/enum.ex:1703: Enum."-map/2-lists^map/1-1-"/2
(ash_postgres 2.4.12) lib/migration_generator/migration_generator.ex:53: AshPostgres.MigrationGenerator.generate/2
(mix 1.17.2) lib/mix/task.ex:495: anonymous fn/3 in Mix.Task.run_task/5
(elixir 1.17.2) lib/enum.ex:1703: Enum."-map/2-lists^map/1-1-"/2
The database tables for my Ash resources are not created because of this error.
I have been able to create migrations in other Ash projects so I have made a mistake somewhere. But when I look at the code from the new project and compare it with similar code from other projects, I’m not seeing where my mistake is.
Where is the config function created for an Ash domain? Where should I be looking to fix this compiler error?
Marked As Solved
MeAndMark
I figured out what the problem was. It was in the postgres section of one of my other resources. I had the name of the domain as the repo instead of the name of the repo.
Problem code:
postgres do
table "posts"
repo ForumApp.Forum
end
Fixed code:
postgres do
table "posts"
repo ForumApp.Repo
end
Thanks for the help. You were on correct about the postgres section being the problem.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








