Action change not running

Hey. Maybe i’m missing something. I have a create action with some global changes but the changes are not running.

actions do
    defaults [:update, :destroy]

    read :read do
      primary? true
    end

    read :list do
      filter expr(owner == ^actor(:id))
    end

    create :create do
      accept [:subject]

      change relate_actor(:owner, allow_nil?: true)
    end

    update :update_todo do
      accept [:subject]
      require_atomic? false
    end
  end

  preparations do
    prepare build(sort: [due_at: :asc, hashes: :asc, title: :asc])
  end

  changes do
    change {Elephouse.TodoList.Changes.Title, attribute: :title}
    change {Elephouse.TodoList.Changes.Hashtags, attribute: :hashes}
    change {Elephouse.TodoList.Changes.DueDate, attribute: :due_at}
  end

If i change accept [:subject] to an argument the changes run just fine.
So i’m missing something or are changes only run with arguments?

EDIT:
Changing it to this it works:

create :create do
      argument :subject, :string
      allow_nil_input [:subject]

      change set_attribute(:subject, arg(:subject))
      change relate_actor(:owner, allow_nil?: true)
    end
1 Like

Found the solution for this one.
In the custom Changes i used Ash.Changeset.get_argument which doesn’t get anything when the action only uses attributes.
So changing that to Ash.Changeset.get_argument_or_attribute got them more flexible and they worked again.

1 Like