Ash FrameworkAF
Ash Framework3y ago
4 replies
Blibs

How to use relationship id in a `get_by` read action

My resource has this relationship:

    belongs_to :customer, Customer do
      allow_nil? true
      attribute_writable? true
    end


This means that this resource table will contain a :customer_id field.

Now I want to create a read action that will filter it by the :customer_id. I can do that by passing that as an argument and doing the filter manually, but I expected that I could use the get_by shortcut here, like this:

    read :get_by_customer_id do
      get_by :customer_id
    end


The problem is that this fails with Ash saying that there is not attribute, calculation or aggregate with that name.
Was this page helpful?