How to import users from csv file with elixir/phoenix?
问题 I have a csv file with a list of users and the following import method inside UserController and I would like to import these users by submitting the csv file with a form. And It looks like I'm doing it wrong. users_controller def import(conn, %{"user" => user_params}) do user_params["file"] |> File.stream!() |> CSV.decode |> Enum.each(fn(user) -> User.changeset(%User{}, %{name: Enum.at(user, 0), email: Enum.at(user, 1)}) |> Repo.insert end) conn |> put_flash(:info, "Imported") |> redirect(to