Ybireder
Ybireder
AEAsh Elixir
Created by Ybireder on 2/4/2023 in #support
Additional attributes in many-to-many relations
Hi there, I'm using a many-to-many relation between two resources. The resources Ingredient and Store are related through the resource Price (an ingredient is available at a store for a certain price). The Price resource has the additional attributes :amount and :price. Ideally, I'd like to have an action on the Ingredient resource to add a store. Somewhat like this:
update :add_store do
argument :store_id, :string, allow_nil?: false
argument :amount, :float
argument :price, :int
...
end
update :add_store do
argument :store_id, :string, allow_nil?: false
argument :amount, :float
argument :price, :int
...
end
This action should create a new price with the given attributes, but I'm struggling to implement the action. On other many-to-many relations, I've used change manage_relationship(:stores, type: :append) but I can't figure out how to add the additional arguments.
5 replies