benonymus

benonymus

Unique_constraint issue

Hey,
I am trying to add unique_contrain to my projects, and it is working beautifully with one of my tables that has only one field, but i with the other one it is not working.
I want to show to the user that a name is already taken on creation or at edit, but it keeps giving me an error that assign @teams not available in eex template.

but I think that the unique_constarint should kick in before this, that it should not get to the point that it redirects, so why is this happening?

the code: https://github.com/benonymus/userteamroleapi

Marked As Solved

Also Liked

pedromvieira

pedromvieira

In addition to those, he should also reference @teams on both new and edit templates (that calls form).

https://github.com/benonymus/userteamroleapi/blob/master/lib/userteam1_web/templates/user/edit.html.eex

https://github.com/benonymus/userteamroleapi/blob/master/lib/userteam1_web/templates/user/new.html.eex

Something like this.

   <%=
    render "form.html",
    ...
    teams: @teams,
    ...
  %>

Last Post!

pedromvieira

pedromvieira

In addition to those, he should also reference @teams on both new and edit templates (that calls form).

https://github.com/benonymus/userteamroleapi/blob/master/lib/userteam1_web/templates/user/edit.html.eex

https://github.com/benonymus/userteamroleapi/blob/master/lib/userteam1_web/templates/user/new.html.eex

Something like this.

   <%=
    render "form.html",
    ...
    teams: @teams,
    ...
  %>

Where Next?

Popular in Questions Top

vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

Other popular topics Top

Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" =&gt; #BSON.ObjectId&lt;58eb1a7a9ad169198c3dXXXX&gt;, "email" =&gt; ...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

We're in Beta

About us Mission Statement