AE
Ash Elixir•2y ago
Jason

Could not relate to actor, as no actor was found (and :allow_nil? is false

When I submit a form that triggers :create action which contains change relate_actor(:author), I get this error. What causes no actor to be found despite that there is a logged in user?
submit_errors: [
author: {"Could not relate to actor, as no actor was found (and :allow_nil? is false)",
[]}
],
submit_errors: [
author: {"Could not relate to actor, as no actor was found (and :allow_nil? is false)",
[]}
],
4 Replies
ZachDaniel
ZachDaniel•2y ago
Did you pass in the actor to the form?
Jason
JasonOP•2y ago
No. 🙂 How do I do that?
ZachDaniel
ZachDaniel•2y ago
You have two ways of setting who the current user is. The most explicit way is to pass it in when creating the form, same way its done w/ changesets Form.for_create(...., actor: socket.assigns.current_user) there is also the process context way, where you set it for everything that happens in the current process Ash.set_actor(socket.assigns.current_user)
Jason
JasonOP•2y ago
Got it. Thank you!

Did you find this page helpful?