Ash.Changeset.change_attribute before or after action
I have this in my seeds.exs file:
What I want to do with this is register a new super user, but I don't have and don't want a specific action to create one since I see it as something that only should be done once in the seeds step.
So what I did was create the changeset that will run my action
register_with_password
, and then I just manually fill the fields that are missing (confirmed_at
and roles
in this case).
This works fine, but I get warnings saying that this will stop working in the future:
At the same time, if I change the order and move the change_attribute
calls up, then my seeds stop working with the following error:
and
What's the correct way to do this?3 Replies
Use
force_change_attribute
, and do it after Ash.Changeset.for_create
Like this right?
Worked like a charm, thanks!
yep!
🥳