Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asynchronous race condition problem #74

Closed
jekku opened this issue May 2, 2017 · 1 comment
Closed

Asynchronous race condition problem #74

jekku opened this issue May 2, 2017 · 1 comment

Comments

@jekku
Copy link

jekku commented May 2, 2017

While trying to upload through cast_attachments/3, I do this in the controller:

  def update(conn, %{"id" => id, "artist" => artist_params}) do # this contains the file params too.
    artist = Repo.get!(Artist, id)
    changeset = Artist.changeset(artist, artist_params)
    case Repo.update(changeset) do
      {:ok, artist} ->
        conn
        |> put_flash(:info, "some message")
        |> redirect(to: somewhere)
      {:error, error} ->
        render(conn, "edit.html", artist: artist, changeset: changeset)
    end
  end

It always goes back to the edit page when cast_attachments/3 is called. When I turn it off, it works correctly. If you pry it in the case results, it will render on its own and the pry would still be available.

Why does this happen?

@jekku jekku closed this as completed May 2, 2017
@jekku
Copy link
Author

jekku commented May 2, 2017

Solved. It was because I was storing the images to priv and it casted a livereload every single time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant