anuvrat

anuvrat

Does manage_relationship document incorrectly ask to specify the relationship before inputs?

The manage_relationship[1] documentation[2] says that relationship has to be specified before inputs:

manage_relationship(changeset, relationship, input, opts \\ [])

However doing so, throws an error.
Also, the example [3] in alembic’s realworld repo, calls the function in this way:

 change manage_relationship(:target_id, :target, type: :append)
 ...
 relationships do
   ...
    belongs_to :target, Realworld.Accounts.User do
      api Realworld.Accounts
      allow_nil? false
      primary_key? true
    end
  end

Why is :target specified after :target_id? Isn’t :target the relationship?


[1] ash/lib/ash/changeset/changeset.ex at v2.21.13 · ash-project/ash · GitHub
[2] Ash.Changeset — ash v2.21.13
[3] realworld/lib/realworld/profiles/resources/follow.ex at 5ddc03e7bc9accfa30327e823450357e56e6c56d · team-alembic/realworld · GitHub

Marked As Solved

sevenseacat

sevenseacat

Author of Ash Framework

You’re looking at two different manage_relationship functions.

The one in the realworld app is a change function, defined here → ash/lib/ash/resource/change/builtins.ex at v2.21.13 · ash-project/ash · GitHub

This calls Ash.Changeset.manage_relationship/4 under the hood, but with the arguments rearranged.

Where Next?

Popular in Questions Top

lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
dokuzbir
Hello, I am trying to convert my lists to string without losing brackets.For start i have 3 map. They look like these buyer = %{ id: ...
New
sacepums
Hey guys. I'm new to elixir and im really stocked about it. But I ran into a bit of problem - I need to convert a date sting, for examp...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
makeitrein
Hey all, just started picking up Elixir last week and am writing a scraper as a learning project. Baby step #1 is extracting the number ...
New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> someth...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New

Other popular topics Top

fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1140 51847 244
New
dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New
AstonJ
by Lance Halvorsen Elixir and Phoenix are generating tremendous excitement as an unbeatable platform for building modern web application...
460 27162 124
New

We're in Beta

About us Mission Statement