i have this models phone.ex and tenant.ex which have an association of belongs_to and has_many respectively. The phone.ex model has one field which is :mobile_number of type :integer. The idea is a tenant can have more than one :mobile_number so in my TenantController for the :create action i have the following code
def create(conn, %{"tenant" => tenant_params}) do
changeset = conn.assigns.current_user
|> build_assoc(:tenants, :phone)
|> Tenant.changeset(tenant_params)
case Repo.insert(changeset) do
{:ok, tenant} ->
conn
|> put_flash(:info, "Tenant created successfully.")
|> redirect(to: tenant_path(conn, :show, tenant))
{:error, changeset} ->
render(conn, "new.html", changeset: changeset)
end
end
I also put the :mobile_number field in the new.html.eex for Tenant template folder so that if given it is populated in the phones table
I get an error which says schema ZitoApp.User does not have association [:tenants, :phone] what could be wrong as per the explanations i have given above? Thank you






















