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