bilalhassankh
Protocol not implemented error in liveviews
Hey, getting this error any solution?? I am using liveviews and livecomponent, trying to list projects that belong to same company in dropdown
<div>
<.form let={f} for={@changeset} phx-target={@myself} phx-change="validate" phx-submit={if @action == :edit_project, do: "update", else: "save"}>
<div class="form-control">
<p><%= gettext("Select Project") %></p>
<%=select f, :user_id, @project_users_options %>
<%= hidden_input f, :user_id%>
<%= error_tag f, :user_id %>
</div>
[error] GenServer #PID<0.14644.0> terminating
** (Protocol.UndefinedError) protocol Enumerable not implemented for %Appeo.Leads.Project{__meta__: #Ecto.Schema.Metadata<:loaded, "projects">, activities: #Ecto.Association.NotLoaded<association :activities is not loaded>, appointments: #Ecto.Association.NotLoaded<association :appointments is not loaded>, buildings: #Ecto.Association.NotLoaded<association :buildings is not loaded>, comments: #Ecto.Association.NotLoaded<association :comments is not loaded>, company: #Ecto.Association.NotLoaded<association :company is not loaded>, company_contact: #Ecto.Association.NotLoaded<association :company_contact is not loaded>, company_contact_id: 3, company_id: 4, contacts: #Ecto.Association.NotLoaded<association :contacts is not loaded>, description: "Mollit numquam non a", estimated_time: 78, id: 3, index: 1.0, inserted_at: ~N[2022-06-08 05:23:51], lead_column: #Ecto.Association.NotLoaded<association :lead_column is not loaded>, lead_column_id: 1, name: "Quamar Garcia", project_buildings: #Ecto.Association.NotLoaded<association :project_buildings is not loaded>, project_contacts: #Ecto.Association.NotLoaded<association :project_contacts is not loaded>, project_image: nil, project_materials: #Ecto.Association.NotLoaded<association :project_materials is not loaded>, project_permission_joined_users: #Ecto.Association.NotLoaded<association :project_permission_joined_users is not loaded>, project_stage: nil, project_start_date: ~U[1992-02-02 03:56:00Z], project_type: "any name", status: :active, tasks: #Ecto.Association.NotLoaded<association :tasks is not loaded>, updated_at: ~N[2022-06-08 05:23:51]} of type Appeo.Leads.Project (a struct)
(elixir 1.13.2) lib/enum.ex:1: Enumerable.impl_for!/1
(elixir 1.13.2) lib/enum.ex:143: Enumerable.reduce/3
(elixir 1.13.2) lib/enum.ex:4144: Enum.reduce/3
(phoenix_html 3.2.0) lib/phoenix_html/form.ex:1293: Phoenix.HTML.Form.option/4
(phoenix_html 3.2.0) lib/phoenix_html/form.ex:1268: anonymous fn/3 in Phoenix.HTML.Form.escaped_options_for_select/2
(elixir 1.13.2) lib/enum.ex:2396: Enum."-reduce/3-lists^foldl/2-0-"/3
(phoenix_html 3.2.0) lib/phoenix_html/form.ex:1241: Phoenix.HTML.Form.options_for_select/2
(phoenix_html 3.2.0) lib/phoenix_html/form.ex:1184: Phoenix.HTML.Form.select/4
(appeo 0.1.0) lib/appeo_web/live/hr_live/dashboard/dashboard_project.html.heex:13: anonymous fn/3 in AppeoWeb.HRLive.DashboardProject.render/1
(phoenix_live_view 0.17.7) lib/phoenix_live_view/diff.ex:387: Phoenix.LiveView.Diff.traverse/7
(phoenix_live_view 0.17.7) lib/phoenix_live_view/diff.ex:494: anonymous fn/4 in Phoenix.LiveView.Diff.traverse_dynamic/7
(elixir 1.13.2) lib/enum.ex:2396: Enum."-reduce/3-lists^foldl/2-0-"/3
(phoenix_live_view 0.17.7) lib/phoenix_live_view/diff.ex:387: Phoenix.LiveView.Diff.traverse/7
(phoenix_live_view 0.17.7) lib/phoenix_live_view/diff.ex:494: anonymous fn/4 in Phoenix.LiveView.Diff.traverse_dynamic/7
(elixir 1.13.2) lib/enum.ex:2396: Enum."-reduce/3-lists^foldl/2-0-"/3
(phoenix_live_view 0.17.7) lib/phoenix_live_view/diff.ex:387: Phoenix.LiveView.Diff.traverse/7
(phoenix_live_view 0.17.7) lib/phoenix_live_view/diff.ex:494: anonymous fn/4 in Phoenix.LiveView.Diff.traverse_dynamic/7
(elixir 1.13.2) lib/enum.ex:2396: Enum."-reduce/3-lists^foldl/2-0-"/3
(phoenix_live_view 0.17.7) lib/phoenix_live_view/diff.ex:387: Phoenix.LiveView.Diff.traverse/7
(phoenix_live_view 0.17.7) lib/phoenix_live_view/diff.ex:664: Phoenix.LiveView.Diff.render_component/9
Last message: %Phoenix.Socket.Message{event: "event", join_ref: "4", payload: %{"event" => "new_project", "type" => "click", "value" => %{}}, ref: "6", topic: "lv:phx-FvaU2LDeNXvo515D"}
State: %{components: {%{1 => {AppeoWeb.LeftNavbar, "left_navbar", %{__changed__: %{}, flash: %{}, id: "left_navbar", myself: %Phoenix.LiveComponent.CID{cid: 1}}, %{__changed__: %{}, root_view: AppeoWeb.HRLive.Dashboard}, {122582042587124548347594463957129459263, %{}}}, 2 => {AppeoWeb.Header, "header", %{__changed__: %{}, current_user: #Appeo.Accounts.User<__meta__: #Ecto.Schema.Metadata<:loaded, "users">, company: %Appeo.Accounts.Company{__meta__: #Ecto.Schema.Metadata<:loaded, "companies">, buildings: #Ecto.Association.NotLoaded<association :buildings is not loaded>, company_contact: #Ecto.Association.NotLoaded<association :company_contact is not loaded>, company_currency: "USD", company_date_format: "MM/DD/YY", company_image: nil, company_language: "English", company_logo: nil, company_name: "invo", company_tenant_url: "invo", company_time_zone: "US/Eastern", contacts: #Ecto.Association.NotLoaded<association :contacts is not loaded>, id: 2, inserted_at: ~N[2022-06-01 07:33:00], updated_at: ~N[2022-06-01 07:33:00], users: #Ecto.Association.NotLoaded<association :users is not loaded>}, company_id: 2, company_name: nil, confirmed_at: nil, current_jwt: nil, email: "test@123.com", employee: #Ecto.Association.NotLoaded<association :employee is not loaded>, hashed_password: "$2b$12$6Rw2ZKjvWtBPGZQ8yX14uurQ5SjBYuzZCSBMZ8Z0kxFp./.r7WStO", id: 3, inserted_at: ~N[2022-06-07 09:29:25], microsoft_token: nil, name: nil, password_set: true, profile: %Appeo.Accounts.Profile{__meta__: #Ecto.Schema.Metadata<:loaded, "profiles">, date_format: "MM/DD/YY", id: 3, image: nil, inserted_at: ~N[2022-06-07 09:29:25], language: "en", name: "test123", phone_number: nil, position: nil, time_zone: "US/Eastern", updated_at: ~N[2022-06-07 09:29:25], user: #Ecto.Association.NotLoaded<association :user is not loaded>, user_id: 3}, provider: "identity", recieve_emails: nil, roles: [%Appeo.Accounts.Role{__meta__: #Ecto.Schema.Metadata<:loaded, "roles">, company: #Ecto.Association.NotLoaded<association :company is not loaded>, company_id: 3, description: "administrator", id: 3, inserted_at: ~N[2022-06-07 09:29:25], name: "Administrator", updated_at: ~N[2022-06-07 09:29:25], user_role: #Ecto.Association.NotLoaded<association :user_role is not loaded>, user_roles: #Ecto.Association.NotLoaded<association :user_roles is not loaded>, users: #Ecto.Association.NotLoaded<association :users is not loaded>}], updated_at: ~N[2022-06-07 09:29:25], user_roles: #Ecto.Association.NotLoaded<association :user_roles is not loaded>, ...>, flash: %{}, id: "header", myself: %Phoenix.LiveComponent.CID{cid: 2}}, %{__changed__: %{}, root_view: AppeoWeb.HRLive.Dashboard}, {5025354630627359592406180085880426220, %{2 => {194566674082730243471037961308665900275, %{}}}}}, 3 => {AppeoWeb.HRLive.DetailsComponent, :dashboard, %{__changed__: %{}, action: :dashboard, current_user: #Appeo.Accounts.User<__meta__: #Ecto.Schema.Metadata<:loaded, "users">, company: %Appeo.Accounts.Company{__meta__: #Ecto.Schema.Metadata<:loaded, "companies">, buildings: #Ecto.Association.NotLoaded<association :buildings is not loaded>, company_contact: #Ecto.Association.NotLoaded<association :company_contact is not loaded>, company_currency: "USD", company_date_format: "MM/DD/YY", company_image: nil, company_language: "English", company_logo: nil, company_name: "invo", company_tenant_url: "invo", company_time_zone: "US/Eastern", contacts: #Ecto.Association.NotLoaded<association :contacts is not loaded>, id: 2, inserted_at: ~N[2022-06-01 07:33:00], updated_at: ~N[2022-06-01 07:33:00], users: #Ecto.Association.NotLoaded<association :users is not loaded>}, company_id: 2, company_name: nil, confirmed_at: nil, current_jwt: nil, email: "test@123.com", employee: #Ecto.Association.NotLoaded<association :employee is not loaded>, hashed_password: "$2b$12$6Rw2ZKjvWtBPGZQ8yX14uurQ5SjBYuzZCSBMZ8Z0kxFp./.r7WStO", id: 3, inserted_at: ~N[2022-06-07 09:29:25], microsoft_token: nil, name: nil, password_set: true, profile: %Appeo.Accounts.Profile{__meta__: #Ecto.Schema.Metadata<:loaded, "profiles">, date_format: "MM/DD/YY", id: 3, image: nil, inserted_at: ~N[2022-06-07 09:29:25], language: "en", name: "test123", phone_number: nil, position: nil, time_zone: "US/Eastern", updated_at: ~N[2022-06-07 09:29:25], user: #Ecto.Association.NotLoaded<association :user is not loaded>, u (truncated)
Most Liked
LostKobrakai
Last Post!
bilalhassankh
This is my update call in livecomponent
def update(
%{
project: project,
action: action
} = assigns,
socket
) do
socket =
socket
|> assign(assigns)
changeset =
ProjectPermissions.change_project_permission_joined_user(
%ProjectPermissionJoinedUser{},
%{project_id: project.id}
)
user = Accounts.get_user!(socket.assigns.user_id)
socket =
socket
|> assign(:user_id, socket.assigns.user_id)
|> assign(:changeset, changeset)
|> assign(:project_permissions, project_permissions())
|> assign(
:project_users_options,
project_users_options(socket.assigns.user_id, user.company_id)
)
|> assign(:project, project)
{:ok, socket}
end
0
Popular in Questions
Lets say I have map like this fetching from my database
%{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
Hi everyone!
I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
Hello!
Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
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
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
Hello all!
I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
Other popular topics
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum.
...
New
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
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
New
Hello all!
I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
After calling mix ecto.create I get this error:
17:00:32.162 [error] GenServer #PID<0.412.0> terminating
** (Postgrex.Error) FATAL...
New
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









