AF
Ash Framework•6mo ago
Kamaro

How To Reuse Business Logic with Ash Calculations and Save Time

6 Replies
allenwyma
allenwyma•6mo ago
404
ZachDaniel
ZachDaniel•6mo ago
Medium
How To Reuse Business Logic with Ash Calculations and Save Time
As your codebase grows, you will realise that you spend less and less time implementing new features. Why? Because the majority of new…
ZachDaniel
ZachDaniel•6mo ago
Thats the right link
Failz
Failz•6mo ago
Nice write up and thank you for sharing. I also like to use calculations to generate urls which helps keep them in one place and if any changes are needed, it's ez pz
calculations do
calculate :edit_path, :string, expr("/admin/users/" <> id <> "/edit") do
description "The admin edit path for this user"
end

calculate :show_path, :string, expr("/admin/users/" <> id) do
description "The admin show path for this user"
end
end
calculations do
calculate :edit_path, :string, expr("/admin/users/" <> id <> "/edit") do
description "The admin edit path for this user"
end

calculate :show_path, :string, expr("/admin/users/" <> id) do
description "The admin show path for this user"
end
end
ZachDaniel
ZachDaniel•6mo ago
clever
allenwyma
allenwyma•6mo ago
i was planning to use this to generate s3 URLs for files that aren't public 🙂

Did you find this page helpful?