Ash Elixir

AE

Ash Elixir

Join the community to ask questions about Ash Elixir and get answers from other members.

Join

support

showcase

today-i-learned

How to: Conditional validation with built-ins

Im trying to validate an embedded field "payment_method" when a certain param/attribute has a specific value. I've tried to do this: ```elixir accept [:collection_method, :billing_cycle_anchor, :customer, :payment_method] validate present([:collection_method, :customer])...

AshCsv - duplication on `upsert?: true`

I might be doing something wrong but when using AshCsv with upsert?: true on a create action, I get duplicates in the CSV file. For context, here's the ressource ``` elixir ...

Does Api.bulk_create support action's arguments?

I'm try to create items that are related to the workspace by using bulk_create ```elixir create :create do primary? true...

Add conditions to upsert

Is there any way to add conditionals when doing an upsert in a create action? For example, I have this resource: ```elixir...

Calculations in AshJsonApi?

Just want to make sure I'm not missing anything obvious - is it possible to include a calculation in a JsonApi request? Including one in the includes list seems to imply it's only looking for resources:
No description

help with ash_geo for using locations.

Resource definition looks like ```elixir defmodule CompaniesRegEx.Resources.Recruiters do use Ash.Resource, data_layer: AshPostgres.DataLayer...

Creating index from identity or custom index creates bad migration

When generating a migration from either an identity or custom index, I'm getting a weird migration: Datalayer: ```elixir postgres do table "plans"...

AshJsonAPI Responses

When updating a resource backed by jsonapi, responses return a 201 instead of 200, is this a bug or am I doing something wrong?

Filtering many_to_many relationships

Hi all I have a many_to_many relationship between two entities (hubs and adverts). I want to have an action that takes an advert_id and returns the hubs to which it's attached to....

Key :editing_tenant not found

Just starting to explore AshAdmin. ```elixir ** (KeyError) key :editing_tenant not found in: %{ changed: %{...

Prefixed base62 UUIDv7 primary key implementation with Ash

Hi all, I'm trying to implement a UUIDv7 based primary key for all our Ash resources (and relationships), storing that as UUID type column on PostgreSQL and presenting that outside as a prefixed base62 string (0188aadc-f449-7818-8862-5eff12733f64 will be shown as acct_02tRrww6GFm4urcMhyQpAS), like what is described here for Ecto (https://danschultzer.com/posts/prefixed-base62-uuidv7-object-ids-with-ecto). I'll be happy to contribute with the result of this as a code sample or better as an elixir package as soon as I get it all working properly. ...

What is the __metadata__ field in new versions of Ash?

I just updated my Ash to the latest version 2.13.2. After that, I noticed that a lot of my unit tests stopped working basically because I was comparing resources. From what I can see, when I create the resource, the __metadata__ field will be a empty map %{}, but when I fetch the same resource with a read action, it will contain a key called selected in that map with the list of fields that were selected....

Need a feature for customizing error message.

i.e. in string type, match constraint will return error message "must match the pattern %{regex}". But, showing regex in user interface is not a good experience for users. I need to customize error messages....

Differences between UUID primary keys in Ecto vs Ash

As far as I can tell, the Ash Resource special attribute uuid_primary_key unwraps into: ```elixir attribute :id, :uuid do writeable? false default &Ash.UUID.generate/0...

Starting a Phoenix/Ash project with minimal cruft

Howdy there. I've been trying the tutorials from the Ash website (both "Get Started" and "Get Started with Ash and Phoenix"). As I was going through, I couldn't help but wonder, "is there a way to do this without Phoenix's Ecto?" In other words, if I'm planning on using Ash for all the domain logic, and Ash is going to use Ecto, can I initialize Pheonix without ecto and still get Ash to work right (since I'll be using Ecto with it)? Context:...

Check a policy manually

Is there a way in Ash to check a policy manually? I want to check if a particular actor has the ability to update a specific resource. I wasn't able to find how to do that. My use case is I'm creating a resource by passing in a Google Cloud storage signed url and I need to check if the path in the signed url is valid. Right now I have this:...

How to insert a record with its nested children?

First, I'd love to thank everyone and especially Zash for the awesome work done in Ash I have a few resources with some relationships between them, for brevity I'll only copy the relevant parts ```elixir...

Ash dropping FilterCheck if there's `authorize_if always()`

Hi, I've got a resource that in it's action has:
authorize_if MyApp.FilterByActorId
authorize_if always()
authorize_if MyApp.FilterByActorId
authorize_if always()
...

How do relationships with composite keys work?

I found this mention of composite keys in the docs: ```elixir has_many :composite_key_posts, MyApp.CompositeKeyPost do destination_attribute :author_id end...

Policy checks on related resources

I have been looking for quite some time so this may be a noob ish question. I have a couple answers potentially but I'd like to know kind of the standard way to write a policy for a resource where the relationship to that resource is how I would authorize the actor. For example Let's say I have a GroupRequest resource which represents a users request to join a group (contains a group_id and user_id) I also have a Group that has a group_admin relationship which belongs to a user....