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

Cancel job Ash Oban

Is there a correct way to cancel a job in ash oban? Specifically, I'm trying to cancel the :respond job in the generated chat in Ash AI if the user wants to stop the response like in other AI chat apps...

Filter by encrypted attribute

I am storing some personal information (national identification numbers,), and encrypting it with ash_cloak. I'd like to implement an action where I search for users given a national identification number as an argument. With the filter
filter expr(national_identity_number == ^arg(:query))
filter expr(national_identity_number == ^arg(:query))
I get this error:...

related Json api to load a resource which is not global multi-tendency when we have master user

Hi Sorry, i think it can not be supported and i should create custom action and call it in api json. but i just want to be sure about it ```elixir base_route "/v1/site/admin", MishkaCms.Runtime.Site do related :error_pages, :read end...
Solution:
You can add a special action for the read action that allows bypassing multitenancy and then only allow an admin user to do that.

Cinder Table and Testing

Thank you for Cinder. Very nice. I have some basic LiveView tests and they are now breaking with Cinder. I believe it is b/c the Table makes the query and the assert is happening before the data is loaded. What is the right fix for this in tests? I can add a timeout but that feels dirty. ```elixir ...

Magic link with registration does not work.

This works just fine if I turn registration off. ``` read :sign_in_with_magic_link do description "Sign in or register a user with magic link." ...

Ash Ai allow multi full text columns

I think rn we can easily avoid this but there are cases where this will be so useful, I am willing to work on this, I already checked the code that handles the full_text macro. However I need some pointers and guides that will help me better understand the library....

How to Use DB/Redis based Sessions with AshAuthentication Instead of JWTs?

Hi everyone! 👋 I just purchased the Ash Framework book from pragstudio.com to learn more about the framework, as I'm hoping to port a legacy Rails app over to Elixir/Phoenix/Ash. When I reached the authentication section, I noticed that it only covers JWT-based sessions for the two chapters on authentication and authorization and there is no mention of database-stored / cookie-based sessions. For my use case, I'd prefer traditional server-side sessions (ideally stored in Redis). Could someone guide me on how I might implement this with AshAuthentication? Any examples, docs, or best practices would be greatly appreciated! 🙏...

Spark - reading child options

Hi All I have defined the following DSL ```elixir...

Forgotten `change` in update action leads to hours of troubleshooting and sadness

I forgot a change in front of a set_attribute in an update action and nothing really reacted to that except that the attribute wasn't set. Is there a flag I can set somewhere to have Spark or Ash or something crash loudly at me when I use keywords in wrong places? Sad code: ```elixir update :set_family do...

Server-side params for AshPhoenix Form

Sometimes I will have an AshPhoenix form to create or update a resource, and I want some of the fields to be provided from the server and not set or visible on the client. Sometimes these are coming from uploads, other times it's computed from other state. What is the best way to provide this data to validate and submit? So far I've been defining a form_params(socket, params) helper that injects/overrides various params before passing the result to validate/submit. This has worked OK but feels wrong, and today I ran into an issue of having to reverse-engineer how AshPhoenix expects unions to work. Appreciate any insight and guidance y'all can provide!...

Claim tenant did not pass validation in multitenancy

Hi, i have multi tendency in my project which let user no tendency or based on his host and put it inside plug For example ```elixir def call(conn, opts) do...
Solution:
Thank you there were some problems in my custom plug 🫄 🚬

Miss understanding to use policy in read action, Handling Missing Actor

Hi sorry again, I've read the documentation multiple times but still struggle to properly handle a case in my :me action. Here’s my current setup: ```elixir...
Solution:
Oh i changed my order of policies it shows :thinkies: 🥲 this was the last line of policies and i move ```elixir bypass always() do...

ashai vectorize

There is an issue where the code keeps embedding vectors even though they were already embedded I am on postgres 16, ``` sudo -u postgres psql -d t_db -c "select count(*) from poems;" count -------...
No description

Ash Authentication ApiKey strategy

How is the correct way to create a ApiKey to be used for users. https://gist.github.com/phsacramento/ad22e42fb4c357d99b694fb8ed511b52 On this example, i'm not able to get generated ApiKey using Api's request....

AshJsonApi.Test post function does not allow change host

Hi, sorry, I think the AshJsonApi.Test post function dose not allow to overwrite the host as a header, is it bug? or i am writing host in bad place? like: ```elixir headers = [{"x-no-tenant", "false"}, {"host", "test.example.com"}] url = "/auth/sign-in#{filds}"...
Solution:
You can pass a tenant option

ash resource force load relationship

How can I force load a relationship, I tried adding Ash.Query.Load in my action but it doesn't take effect.

Prefix changes the Api path in SwaggerUi but Not Acceptable

Hi sorry, I set prefix "/api/v1" in my json_api and it is changed inside SwaggerUi to this prefix. For example /api/v1/auth/sign-in like this ```elixir json_api do prefix "/api/v1"...
Solution:
Just change the route that you serve the api at in your router

Bypassing Multitenancy on Destroy Actions

My goal is to delete any invitation that is expired using a cron job (Oban) ```elixir destroy :delete_expired_invitation do multitenancy :bypass filter expr(expires_at <= now())...
Solution:
This is working though ```elixir MyApp.Establishments.Invitation |> Ash.Query.for_read(:expired)...

Anonymous users with AshAuthentication

Context As a part of the app I'm currently building, there will be anonymous users as well as "authenticated" users that log in with email and password or other strategies. Authenticated users will create entities that can be shared through generating a public link. Anyone with the link will be able to view and comment on the entity created by the authenticated user. However, the comments still need to be tied to a user because only they should be able to do things like delete or edit sent comments. Question Does anyone have a recommended way to handle anonymous users? ...

Managing Relationships - Cascading deletes for has_one relationships.

I'm trying to work through setting up relationships the Ash-way and here's roughly the structure I have: * A Campaign Has One Ship Has One Stash ** Has Many Crew Members...