many_to_many update problem
I have a
product
which has many_to_many tags
. Creating works. Updating doesn't. Here's the resource code:
lib/app/shop/resources/product.ex
Here's what I do in the iex:
That all works nicely. But I can not update the products tags or the even the product:
How can I fix this?6 Replies
Hey there! I could be totally wrong but I think from memory if something is stated as an
argument
you have to just pass it as App.Shop.Product.update!(banana, [yellow_tag])
rather than in a struct (I think), and additionally may need to include args: [tags]
in your code interface for the update action. Hopefully that helps? I could be totally wrong as I tend to always mix up argument
and accepts
and the correct syntax for calling them 😅I tried
But I don't know how to do the
args: [tags]
thing and I am lost in the documentation.
@Zach Daniel Can you help me out here? I'd like to record the tutorial.You’ve defined your action called
:update
but is a create action
So the first argument would be different, causing the error you see
We should provide better error there of course
But it should work if you change it to an update action
I.e create :update
I draw a blank here. The code already says:
Where would I include an other create?
It should say
update :update
Not create :update
Ahhh! Thanks! It works.