AF
Ash Framework•4mo ago
Kamaro

How To Reuse Business Logic with Ash Calculations and Save Time

6 Replies
allenwyma
allenwyma•4mo ago
404
ZachDaniel
ZachDaniel•4mo 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•4mo ago
Thats the right link
Failz
Failz•4mo 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•4mo ago
clever
allenwyma
allenwyma•4mo ago
i was planning to use this to generate s3 URLs for files that aren't public 🙂

Did you find this page helpful?