bilalhassankh

bilalhassankh

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)

Showing Posts 1 to 3

LostKobrakai

LostKobrakai

You’re passing it a single project though, not a list.

bilalhassankh

bilalhassankh OP

This is how I am getting those project list
defp project_users_options(user_id, company_id) do
project_users = Leads.get_project_by_project_permission_joined_user(user_id, company_id)
end

def get_project_by_project_permission_joined_user(user_id, company_id) do
Repo.tenant_checkout(fn →
from(
project in Project,
join: pp in ProjectPermissionJoinedUser,
join: c in Company,
on: pp.project_id == project.id,
where: pp.user_id != ^user_id,
where: c.id == ^company_id
)
|> Repo.all()
end)
end

bilalhassankh

bilalhassankh OP

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

— 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
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
matt-savvy
Anyone here using Honeybadger? My Honeybadger account is being overwhelmed with noise from some bots. Seeing a lot of Bandit.HTTPError...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
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
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
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
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
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

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews