Ash Framework

AF

Ash Framework

The Elixir backend framework for unparalleled productivity. Declarative tools that let you stop wasting time. Use with Phoenix LiveView or build APIs in minutes for your front-end of choice.

Join

support

showcase

today-i-learned

destroy unmatching related associations

I'm currently trying to destroy the associations in case the attribute is an empty list with this change ``` change manage_relationship(:owner_teams, :owner_teams, type: :direct_control,...

AshPhoenix checkboxes acting wonky

My form (slightly abbreviated): ``` <.form for={@form} id="storefront-form"...
Solution:
Had claude check my input components against a fresh phx.new core components and now it all works. Thank you for that (in hindsight) obvious place to look. I have been debugging like crazy lol.

Membership FilterCheck

Hello lovely people 👋 I’ve been working on a custom SpaceMemberFilter policy check (using Ash.Policy.FilterCheck) with a goal to authorize access if the actor is a member of the space associated with a given resource (optionally filtered by actor’s role in given space). I took inspiration from Ash.Policy.Check.RelatesToActorVia, but instead of comparing to a single actor ID, I need to check whether the resource’s space_id is in the list of the actor’s valid space memberships....

Custom on option on update action

What is the idiomatic way to pass a custom option to an action. Id like to achieve the following:
update_contact_cool_action(contact, attrs, push_sync: false)
update_contact_cool_action(contact, attrs, push_sync: false)
...

Table renamed but old table remains

Hi all. I renamed a table from automobiles to cars like this: ``` postgres do table "cars" # Used to be automobiles...
Solution:
mix ecto.gen.migration gets you a one-off migration

Invalid Filter Reference

I'm getting an Ash.Error.Query.InvalidFilterReference I'm trying to push a particular filter into the DB level. I have this calculation, which works: ```elixir...

How do I make a query require authentication and return an error if the user is not logged in?

Currently, the query returns nothing when there is no user logged in. But I would like it to return an authentication error.

AshAi tools

how do I get the schema of a tool?

Grab my user's tenant name so I can display it

I am currently doing something like this in order to grab my user's tenant. Is this the correct approach? ``` pipeline :browser do plug :accepts, ["html"]...
Solution:
sign in does not share state with your liveview, but you can put the tenant name in the session

AshAi tool calling

I have a weird case where most of the fields are arrays, and when the ai triggers a tool call it checks equality instead of inclusive-ity, is there a way to combat this. it's using the underlying filter option so I think it know that the attribute is an array but it's using equality [:eq] instead...

Tenant registration on sign-in.

Can someone point me in the right direction to implement the below flow for GitHub-only auth? Case 1: User exists and belongs to an org -> User is signed in via GitHub ...
Solution:
If not, then you can just put something in the router for if the user is signed in but has no organization_id they get sent to a different page

Prevent accessing route if logged in

Is it possible to prevent a user from accessing a page if already logged in? I remember vanilla Phoenix having something like :redirect_if_user_authenticated but I can't find the Ash way to achieve this....
Solution:
You could do it at the router level, but you could also add a policy on the action

Windows has problems PendingCodegen after `ash.setup`

Hi in mac os i have no problem. in windows when My colleague clone the project and fresh install (after create db and migrate all migrations) , it gets this error in my phoenix project! (without any new changes) or changing anu resource code! ``` mix ecto.drop; mix ash.setup; mix run priv/repo/entry_dev_test_seeds.exs ; iex -S mix phx.server ...
Solution:
I just honestly don't think I have the bandwidth to support windows at this point, someone else will have to figure out this strangeness
No description

Confusion with before_transaction timing and doing changes before manage_relationship

Hello, I am basically trying to use the data from a third party API call to create a related resource in manage_relationship. Reading the doc I decided that it would make sense to call the API in a before_transaction hook. The docs is stating the following execution order for a create action: ```...
Solution:
Changes/validations run and then when you call the action before_transaction hooks are the first hooks to run

Conversion of strings with just whitespace when storing in postgres

We are moving data from old systems to a new system and noted that one entry had a tax number of " ". Now, that is not a valid tax number, but we realized that the corresponding DB row has a value of null instead. Is this the default behaviour for strings that contain only whitespace? Is there an option to disable this behaviour and what are the caveats if we do?...

manage_relationship not creating many-to-many join records

I'm having trouble getting manage_relationship to work with a many-to-many relationship where the destination resource uses a non-standard primary key. Setup I have a many-to-many relationship between Device and Pass through a DeviceRegistration join table:...

Drastic slowdowns

Hi! I'm getting crippling slow responses from Ash for simple queries. For example: ``` [debug] HANDLE EVENT "sort" in TalksWeb.OutlineIndexLive Parameters: %{"field" => "title"} ...

Guides for using ashflow

Can't find any guides on how to use ashflow, and the documentation doesn't specify anything

Aggregates based on resources keep failing

```elixir defmodule YourApp.Poetry.Topic do alias YourApp.Poetry.Poem use Ash.Resource,...

How to upsert multiple rows atomically?

How do you update multiple rows in one go, making sure each update is atomic and either all succeed or all rollback? My use case: updating stock for an item across several warehouses. ```...