Return resource A from an action on resource B
I am working on an invite-only application. I have a
The
My understanding was that the return value of the
And in the stack trace it is because the returned struct is an
Is what I'm trying to do (a) possible, and (b) reasonable, or should I go about it in some other way?
User resource and an Invitation resource. I would like to create an :accept_invitation action which validates an invitation record, creates a user, and returns the user. This is what I have attempted so far:The
CreateUserFromInvitation change looks like this:My understanding was that the return value of the
after_action beccomes the return value of the whole action, but this test fails:And in the stack trace it is because the returned struct is an
Invitation.Is what I'm trying to do (a) possible, and (b) reasonable, or should I go about it in some other way?
Solution
This seems to have done the trick:
Was a little surprised to see the warning when using
Was a little surprised to see the warning when using
change_attribute instead of force_change_attribute, so opened a PR with a suggestion of updating the docs as well: https://github.com/ash-project/ash/pull/2258GitHub
Using change_attribute/2 in a before_action hook triggers a warning that the changeset has already been validated, suggests a new pattern that isn't compatible with the before_action hook. ...
