Terris
Terris
AEAsh Elixir
Created by Terris on 7/7/2023 in #support
How should module calculations return errors?
Since the name of the function calculate/3 doesn’t end with ! and returns a raw value instead of an ok/error tuple, I’m just checking whether it’s OK for my custom calculation (defined in its own module) to raise an error which can be caused by, say, an attribute having a value of an unexpected type or an invalid string format (this would be caused by a bug in the app — I’m not trying to code a validation in a calculation).
9 replies
AEAsh Elixir
Created by Terris on 7/4/2023 in #showcase
Friendlier ids: base62 with resource type (mentioned recently for Ecto on Thinking Elixir)
Livebook: https://gist.github.com/dev-guy/51a4c12983424d3480cd1201263b50c9 This is what I could do in about 24 hours. Ash experts could do something much better than this.
1 replies
AEAsh Elixir
Created by Terris on 7/2/2023 in #support
CRDT and Ash
First of all: Why use Ash? Because declarative programming and Elixir are awesome. Why CRDT? Because they are awesome too - anyone who's dealt with LiveViews losing their sockets knows what I mean. I'm using Rustler to talk to a Yjs (the package is Rjs which is pronounced 'wires'). A NIF written in Rust accepts an Ash resource instance and creates a Yjs document from it. I am contemplating how to do this in a generic way, and it appears that, while I might be able to code an Ash extension for this, it won't work with Rust serde. I'm contemplating using Json instead since it works bidirectionally between Ash and Yrs. Are there any gotchas I should be aware of when serializing Ash structs to Json? Would at least parts of JsonApi be of help? I haven't thought a lot about references yet but I think they will be links instead of being embedded. Every resource will have its own Yrs document. For now, this is just a fun experiment for learning CRDT and Rustler. Thanks!
5 replies
AEAsh Elixir
Created by Terris on 5/22/2023 in #support
Modeling Context Multitenancy
The goal is to have a Tenant be identified by a subdomain (I think this is the common usage). I want to use schema/context multitenancy. There is a User resource in the "master" database (master registry?) who are admins that manage tenants. There is another User resource (ideally inheriting from the master User) that represents a user in a tenant. I'm getting back to this thread a month later: https://discord.com/channels/711271361523351632/1098462406109311108/1098614600917852231 in which @Zach Daniel recommended a context-tenanted User resource and an attribute-tenanted Organization resource. Am I missing another resource like Tenant? Otherwise how would attribute-tenancy work for Organization?
10 replies
AEAsh Elixir
Created by Terris on 5/22/2023 in #support
Modeling roles for access control
Role enforcement will be done via policies. Is it better to add each role to a User as a property or should I create a Role resource and add a relationship between User and Role? Seems like having a separate Role relationship would make pick screens easier; otherwise I'd probably be hard-coding them.
5 replies
AEAsh Elixir
Created by Terris on 5/21/2023 in #support
Log in with username and password in Phoenix app
Does ash auth Phoenix have a declarative way to log in with username instead of email address? I changed my resources but it looks like I need to change something else.
12 replies
AEAsh Elixir
Created by Terris on 4/19/2023 in #support
Ash-Postgres and uuidv7
This might be an Ecto question. If I add a Postgres function uuidv7(), can Ash use it when creating new resource instances? If not, could Ash use such a function in Elixir (that would probably be faster anyway).
8 replies
AEAsh Elixir
Created by Terris on 4/18/2023 in #showcase
Ash Twitter: An example Ash application by @zachdaniel
Author: @Zach Daniel As featured in LiveView Mastery episodes from January 2023 (posted here previously): Code: https://github.com/zachdaniel/twitter Part 1 https://youtu.be/8Ll31HK9GSU Part 2 https://youtu.be/pwxShYmJgkk
2 replies
AEAsh Elixir
Created by Terris on 4/14/2023 in #showcase
Phoenix+Ash+Svelte : Better together
This is the beginning of an Ash project using Svelte for responsive UX and collaborative editing via TipTap coming soon. It will become a daily team diary but it's mainly a tool for you and I to learn how to get up and running with performant code fast. This is the result of about 30 hours of mostly client-side work. I spent more time on styles than I expected but I should have known better. This is an experiment in technology as well as "working in public." While nothing will be earth-shattering, I think you will be surprised by how few lines of actual code (Elixir on backend, JavaScript on frontend) will be written. https://github.com/dev-guy/ash-svelte-flowbite
11 replies
AEAsh Elixir
Created by Terris on 4/8/2023 in #support
Ash+Phoenix+Authentication Starter
I went through “Getting Started Ash Authentication Phoenix” yesterday, but if I want the “forgot password” flow, it looks like we should instead copy the dev subdirectory in the ash_authentication_phoenix repo and rename modules and directories. Is that the recommended way?
17 replies