Ash FrameworkAF
Ash Framework3y ago
4 replies
jart

How best to model partial updates of optional attributes?

The classic example is a "user settings" page, where if they only change their username but leave the password field blank, you want to not update the password, but instead ignore it.

The best I can come up with is something like this:

update :update do
  change prevent_change(:password), where: [absent(:password)]
end


Is there a better way to achieve this?
Was this page helpful?