gvanders
AEAsh Elixir
•Created by gvanders on 5/10/2023 in #support
Polymorphic Embedded Resources?
Is it possible to have embedded resources be one or more structs
for example
Thinking either this is not supported or could be done with some sort of custom type?
14 replies
AEAsh Elixir
•Created by gvanders on 4/28/2023 in #support
Nested embedded Resource Form
I have an embedded resource which contains multiple other embedded resources. When I use
AshPhoenix.Form.for_update
with forms: [auto?: true]
, the form created does not contain information about any of the embedded resources other than the first key.
Right now I am adding the missing data like so
Is there something I have to set up in the update action of the root level embedded resource?
Additionally, when adding the form in assigns after validation, the diff sent over the wire is huge. Any tips on reducing the payload for large forms? Splitting up something in some way?28 replies
AEAsh Elixir
•Created by gvanders on 4/19/2023 in #support
Reading Tenant ETS resources returns empty array
I am trying to read a tenanted ets resource but always getting empty list when trying to read, though creates are "successful".
Below is my IEX session
10 replies
AEAsh Elixir
•Created by gvanders on 4/18/2023 in #support
Patterns for Propagating Tenants to LiveComponents/LiveViews?
This is a Noob / organizational question. But I just added attribute multi-tenancy to my app. I have the correct tenant loaded on login, placed in the conns, and in the session via
ash_authentication.phoenix.livesession
. I am grabbing the tenant from session
in a LiveView to be added to reads
. For handle_events, and all LiveComponents
which talk to the DB, I assume I'll need to pass the tenant in via assigns? Feels like it could get a bit messy, especially for LiveComponents. Does anyone have a pattern they like to use14 replies
AEAsh Elixir
•Created by gvanders on 4/17/2023 in #support
AshAuthenticationPhoenix Override Register Form
I want to add a form field on the register form, specifically tenant information for attribute based multitenancy. I see that there is a
register_extra
slot which receives the form, so I was thinking I could use that.
Is there a way to override just the Password.RegisterForm to a custom component (assuming that is how I'd add the slot)?6 replies
AEAsh Elixir
•Created by gvanders on 4/13/2023 in #support
Change storage_type of Ash.Type.Term to :binary?
When trying to persist a Term to postgres, I got this error because the term type is string. Changing the storage type/rerunning migrations fixed the issue for me. I can open up a PR if this change seems to make sense to you
** (Postgrex.Error) ERROR 22021 (character_not_in_repertoire) invalid byte sequence for encoding "UTF8": 0x83
10 replies
AEAsh Elixir
•Created by gvanders on 3/22/2023 in #showcase
Ash Application Template
Attached is a LiveBook template which starts up an Ash / LiveView application with with a few basic things set up. This sets up a resource and shows an example of inserting and reading the data. Additionally it is has graphql set up, so the resource is served on the playground. Hopefully this can serve as a starting off point for people who want to create recipes highlight certain features, to isolate behavior so others can more easily help in debugging, or anything else you may find useful
3 replies
AEAsh Elixir
•Created by gvanders on 3/16/2023 in #support
Auto forms silently drops some associations
I ran into this while trying to use auto forms, grabbing values from the created
_join
form. There were no errors, but not all of the resource associations were present. Looks like here https://github.com/ash-project/ash_phoenix/blob/main/lib/ash_phoenix/form/auto.ex#L469 we use Enum.find
, so we are only getting the first occurence of the association. I tried editing it to Enum.filter
and changing the type from :single
to :list
. This made the associations properly appear in the form, but submitting it failed.
Got me wondering a few things. First, maybe I screwed up somewhere before 😅 . Secondly for fixing it if it is a bug, it doesn't seem like we can know :single or :list beforehand , so would we need to use an anonymous function to resolve which similar to how data is resolved?
Alternatively, is it possible to just make them all :list
and handle the length = 1 case for single?28 replies
AEAsh Elixir
•Created by gvanders on 3/14/2023 in #support
Loading related resource, filtered using a property on the Join Table
https://hexdocs.pm/ash/relationships.html#more-complex-data-loading
Looking here I see I can specify a query for the loaded resource which is sweet. What I'm wondering is if we have some metadata about the relationship present on the join table, what is the right/ash way to filter the loaded tables? A contrived example would be check User A's relationship to other users, filtered on created_date or some enum. Specifically for many_to_many, though I assume the answer would apply for all
55 replies
AEAsh Elixir
•Created by gvanders on 2/24/2023 in #support
:one_of constraint for type string
There exists :one_of constraint for type :atoms on the resources, but this does not exist for type :string. Is there another way to restrict values to one of a list of strings?
18 replies