How to set the actor within an action
Hey everyone!
Currently, we have an action that takes a
user
as an argument:
I know that I can use change relate_actor(:user)
to set the actor but that would require me to update the function signature everywhere. Is it possible to set the actor within an action using one of the available arguments? Thanks!4 Replies
It is possible, but could you tell me more about what you're trying to accomplish?
Hey Zach! We recently created an
Ash.Resource.Change
module to have additional scoping for some of our resources. In order for that to work correctly, it requires an actor via
which is why I want to set the actor.Gotcha. So, that may not work the way you want to even if you do set the actor into the changeset's private context 🤔
Which is something you can do, but I don't think it would get set into the context of subsequent changes
My suggestion is to "figure something else out", since setting the actor isn't really true, i.e it wasn't that user who initiated the change.
i.e use arguments or changeset context instead
sounds good. thanks!