code_interface not expose function

Hi guys, I have a resource like this:
defmodule OrangeCms.Content.ContentType do
use Ash.Resource,
data_layer: AshPostgres.DataLayer

...
code_interface do
define_for(OrangeCms.Content)

define(:open, action: :create, args: [:subject])
end
...
end
defmodule OrangeCms.Content.ContentType do
use Ash.Resource,
data_layer: AshPostgres.DataLayer

...
code_interface do
define_for(OrangeCms.Content)

define(:open, action: :create, args: [:subject])
end
...
end
But when I tried calling open, I got this error
iex(1)> OrangeCms.Content.open(%{subject: "hello"})
** (UndefinedFunctionError) function OrangeCms.Content.open/1 is undefined or private
(orange_cms 0.1.0) OrangeCms.Content.open(%{subject: "hello"})
iex(1)> OrangeCms.Content.open(%{subject: "hello"})
** (UndefinedFunctionError) function OrangeCms.Content.open/1 is undefined or private
(orange_cms 0.1.0) OrangeCms.Content.open(%{subject: "hello"})
Did I do anything wrong with the code?
4 Replies
ZachDaniel
ZachDaniel•3y ago
The function is defined on the resource 🙂 OrangeCms.Content.ContentType.open
dungnguyen8134
dungnguyen8134OP•3y ago
Thank you for your help. I'm quite new to Ash. I'm using it for my side project.
ZachDaniel
ZachDaniel•3y ago
Glad to be of help. Hope you find the framework enjoyable to work with 🥳
dungnguyen8134
dungnguyen8134OP•3y ago
It takes time to get familiar with Ash. But it reduces lot of boilerplate. Thank you for your awesome work.

Did you find this page helpful?