Define_calculation incompatibility

I am loving the new Ash Framework beta book (and highly recommend it to all). There is so much great material in it and I am enjoying all of the time I spending with it.

Thank you Rebecca & Zach for writing it.

I’m working in Chapter 7 about “all things testing” and am on page 184, where you are discussing testing calculations and make use of the define_calculation DSL.

The issue I have come across is that this doesn’t seem to be compatible with the AshPhoenix module - included as an extension at the top of the Music domain module.

It seems to expect there to be an :action key on the definition in the domain.

It errors at line 93 in ash_phoenix.ex:

defp add_form_interface(interface, dsl_state, resource, resource? \\ false) do
  name = :"form_to_#{interface.name}"

  action =
    if resource? do
      Ash.Resource.Info.action(dsl_state, interface.action || interface.name)
    else
  --->>>>    Ash.Resource.Info.action(resource, interface.action || interface.name)
    end

Clearly, the definition of the calculation in the domain doesn’t need/know the action.

Please let me know if I can help further with this.

Thanks again
Martin

1 Like

Yikes, I will look into this. It should be ignoring those ones :slight_smile:

Hmm…could you share your current define/define_calculation code?

Ah, okay I found the issue :slight_smile:

I’ve fixed this and released a new version of ash_phoenix v2.1.16. You can mix deps.update ash_phoenix to get the fix.

1 Like