How to access other tables with nil value – Questions / Help


Hey
I create a liveview with the generator. But from the index.html.heex file I want to connect other tables. Because of that I create the function “list_owner_1”

<.input field={@form[:owner_id]} type="select" label="Owner" options={Persons.list_owner_1() |> Enum.map(&{&1.owner_d, &1.id})} />

def list_owner_1 do
(from s in Owner, select: %Owner{id: s.id, owner_d: fragment(“concat( ?, ’ ‘, ?)”, s.firstname, s.surname)})
|> Repo.all
end

That is working. But it fails if there is no value. In this case I get a error because nil is not allowed. Are there other possibilitys?



Source link

Leave a Comment