TwistingTwists

TwistingTwists

I have the following resource and api structure

resource : PyqRatta.Databank.Question
resource: PyqRatta.Databank.Quiz has_many PyqRatta.Databank.Question
api : PyqRatta.Databank[PyqRatta.Databank.Quiz, PyqRatta.Databank.Question] (list of resources in api)

and

resource : PyqRatta.QuizPractice.Response belongs_to PyqRatta.Databank.Question
api : PyqRatta.QuizPractice[PyqRatta.QuizPractice.Response] (list of resources in api)

now, in response.ex


    relationships do
        belongs_to :question, PyqRatta.Databank.Question,
          attribute_writable?: true,
          attribute_type: :integer,
          allow_nil?: false
    end

I am getting error. App Name is PyqRatta

* (EXIT from #PID<0.93.0>) an exception was raised:
    ** (RuntimeError) Resource `PyqRatta.Databank.Question` in relationship `:question` is not in api `PyqRatta.QuizPractice`. Please do one of the following

1. add the resource to the api `PyqRatta.QuizPractice`
2. configure a different api

I can see the relationship can be used for resource in different api.
Here, Red.Accounts.User is in api Red.Accounts and Red.Practice.Card is in api Red.Practice.
https://github.com/dewetblomerus/red/blob/ee1aab452d35cfe1687791d8e9423b32f26e915a/lib/red/practice/resources/card.ex#L111-L117

Why does it work in case above and not in my case?

Showing Posts 1 to 3

TwistingTwists

TwistingTwists OP

when i move resource PyqRatta.QuizPractice.Response to PyqRatta.Databank api, the relationship works. (as suggested by ash)

Ideally, I would like these to be in two separate contexts.

MRdotB

MRdotB

You need to use the api option when doing cross api relationships.

    relationships do
        belongs_to :question, PyqRatta.Databank.Question,
          api: PyqRatta.Databank,
          attribute_writable?: true,
          attribute_type: :integer,
          allow_nil?: false
    end
TwistingTwists

TwistingTwists OP

Just fo future ref, here are the docs.

— All posts loaded —

Where Next? Top

Trending in Questions Top

Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
Onor.io
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
Trolleger
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
matt-savvy
Anyone here using Honeybadger? My Honeybadger account is being overwhelmed with noise from some bots. Seeing a lot of Bandit.HTTPError...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge &amp; Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews