Create Resource without relation
Hey guys, I'm dipping my toes into Ash and try to build a small thing, but now I'm stuck. I created a resource and a relationship. I want to create the resource, but the relationship can be empty. But when I try to create the resource, I get this error:
The resource is defined as:
And the corresponding relation:
I can't figure out, what I'm doing wrong, because it works like this in the getting started guide: https://ash-hq.org/docs/guides/ash/latest/tutorials/get-started#working-with-relationships. I'm sure I'm missing something obvious...
21 Replies
Welcome! π
Is the first resource the full definition?
...perhaps I broke something with the relationship -> assoc interop??
@fummmp can you post more of the stacktrace?
@frankdugan3 have you tried out your app against the new branch with this interop?
sorry, the new release π
not on a branch
Not the large app. The small app I'm working on that's up to date, don't think I have any
belongs_to
that can be nil. Otherwise, haven't noticed any problems yet.welp
ash_postgres tests are failing with the new ash changes, oops
with that same error
Ooh, ouch! lol
will fix now
Sure
Thank you for the quick reply! It's mostly complete but here's the full module
Should have a new version of ash_postgres in with a fix soon
fix in
v1.3.4
@Zach Daniel you are amazing!
π thanks for the kind words. Thanks for reporting the issue so we could fix it quickly.
If your issue has been resolved, please add the Solved tag and close this thread by right clicking the thread in the sidebar and choosing Close Post.
I saw part 1 of the video yesterday and it finally made me try Ash. Excited for part 2! π
Oh wow! You absolutely made my day now! β€οΈ
Will try tomorrow! Now I need some sleep..itβs 3AM here in Germany π
π go to bed
@Zach Daniel you're my hero! It works! Thank you again for the more than quick response and the effort to fix the bug immediately!
Hi @fummmp, quick question: in the
belongs_to
relationship, why do you add the line starting with api
? Also, does attribute_writable? true
make the relationship capable of being defined by passing the relevant ..._id
during the :create
action?On https://www.ash-hq.org/docs/guides/ash/latest/topics/relationships.md there is no such
api
line explained.You can have different API modules per e.g domain. If the related items are in configured in APIs you need to tell Ash which one to use.
Ash HQ
DSL Entity: ash > Resource > relationships > has_many
View the documentation for DSL Entity: ash > Resource > relationships > has_many on Ash HQ.
in the DSL docs we explain each individual option
@barnabasj aha, so if I only have one domain, then I don't need it -- but, e.g., if I wanted to make a relationship between the resource in my domain and a resource in ash_authentication's accounts domain, then I use the api option?
got it, thanks!