sezaru

sezaru

Support for code_interface in embedded resources

I’m upgrading Ash from 2 to 3. Before I had a create action with a code interface in my embedded resource like this:

defmodule Coupon do
  @moduledoc false

  use Ash.Resource,
    data_layer: :embedded

  code_interface do
    define :new
  end
  ...
  actions do
    create :new, primary?: true
  end
end

I expect that a function Coupon.new/1 will be created, but that doesn’t seem to be the case, did something changed regarding this from 2 to 3? I can’t find anything regarding this in the upgrade documentation.

Marked As Solved

zachdaniel

zachdaniel

Creator of Ash

Interesting…I honestly hadn’t even considered having a code interface on an embedded resource. You’ll need to set the domain option inside the code_interface block:

  code_interface do
    domain TheDomain.ToUse
    define :new
  end

If you don’t want to use an existing domain, you can do this:

defmodule EmbedDomain do
  use Ash.Domain

  resources do
    allow_unregistered? true
  end
end

Where Next?

Popular in Questions Top

JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

Other popular topics Top

minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 54996 245
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 44167 214
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New

We're in Beta

About us Mission Statement