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

Recognizing Phoenix.Endpoint when using SiteEncrypt.

Would it be possible to recognize the endpoint if one is using SiteEncrypt?
The use statement is then use SiteEncrypt.Phoenix.Endpoint, otp_app: ... instead of the regular one. this causes packages like tidewave to not recognize the endpoint....

AshAuthentication + custom api login = ?

I want to create a custom authentication flow for a simple POST /api/auth/login endpoint where I get the username and password from the user of the API. I've found the example of how to write an APIAuthController pasted below, and I've put it in its own file in my project, but I don't know how to fit this into my router, what's the next obvious step that my tired and caffeine fueled brain doesn't realize? I had a talk with both ChatGPT and Claude.ai about this too, and they sent me down one rabbit hole each, so this is getting exciting! 😄 ```elixir...

Cascading delete and pub_sub

Hi @everyone, I have a resource (Notification) ```elixir ...
Solution:
anytime 🙂

Password reset error when using Sqlite

On a newly created Ash project using Sqlite I get the following error when attempting a password reset: [debug] QUERY ERROR source="users" db=0.0ms idle=444.2ms UPDATE "users" AS u0 SET "confirmed_at" = CAST(CAST(? AS TEXT) AS TEXT), "hashed_password" = CAST((CASE WHEN REGEXP_REPLACE(REGEXP_REPLACE(?, ' +$', ''), '^ +', '') = ? THEN NULL ELSE REGEXP_REPLACE(REGEXP_REPLACE(?, ' +$', ''), '^ +', '') END) AS TEXT) WHERE (CAST(u0."id" AS TEXT) = CAST(? AS TEXT)) RETURNING "id", "confirmed_at", "email", "hashed_password" [~U[2025-08-20 19:00:06.675262Z], "$2b$12$fFi1OtgfaPfaDBLQHyz3h.fS3bjMSUUgXVMl9h5UVBm8rocZELAea", "", "$2b$12$0C5BBQvboelGhbfi3n/3geoEf/0AQbwMOEZlpWNNqoh8btxY/qe1K", "6da84435-84cd-4827-8ec9-55c56b08dc5e"] ...

How can add an action in Mixin?

Hi sorry, this is my Mixin to create version for my records, how can add an action inside it? ```elixir defmodule MishkaCms.Runtime.Resources.Mixins.PagePaperTrailMixin do def postgres do quote do...
Solution:
yes, that should work

Not sure how to apply a policy on an attribute of a resource. Keep getting an error.

I have a policy for a resource called user_tokens which is just a way to test a user sign up. User enters phone number and user_tokens will save and send an otp to the mobile number. To avoid abuse, there is a status column which when "locked" should stop sending the SMS. I tried the things as the error suggested but could not overcome the problem yet. Also searched the prior posts but yet to find an answer. Very new to Ash, but hopefully I am not bugging and taking up much of your time in the process of getting past my learning curve. Apologies if I am. ``` policy action_type([:create]) do forbid_if expr(status == :locked)...

Master user token can not update/destroy a global false multi-tenancy resource

Hi sorry, I think have a mistake in using actions Imagine you are a master user (has who has not tenancy ) , now you want to update a a global false multi-tenancy resource record! So because it is master user and has no tenancy i created :get_any action, my code set tenancy nil for master user on plug level ...
Solution:
You'll have to use generic actions for a lot of things in that setup

is it possible to use AshApi schema-less

I just wanna use the DSL to define business logic routes, without interaction with database is it possible?...

Migrations are applied incorrectly with multiple repos

Hi all 👋, I’m working on a project that uses multiple Repos to avoid pool exhaustion. I ran into the issue described here on ElixirForum: 👉https://elixirforum.com/t/migrations-are-applied-incorrectly-in-all-repos/61082 ...

Improving incremental compilation times

Hi there! I need to know what the best practices are when working with Ash resources and related files (calculations, preparations, etc), specifically around avoiding unnecessary dependencies and keeping compilation times low. Things to do, and what not to do. I originally posted about this on the Elixir Forum (https://elixirforum.com/t/reducing-incremental-compilation-times-in-phoenix-ash-project/72113). The feedback there helped me better analyze my codebase and realize that I may be doing something wrong within Ash resources — and related files — myself, which has increased recompilation times (up to 10s). My gut is telling me that what I'm doing here might be wrong:...
Solution:
```elixir defmodule Your.Resource.Changes.SendInvitationEmail do use Ash.Resource.Change def change(changeset, , ) ->...

Embedded Resource default value causes compilation error

I have a fairly simple embedded resource: ```elixir defmodule App.Organizations.OrganizationSettings do @moduledoc false ...
Solution:
default: fn -> %{} end in this case

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...