-
Notifications
You must be signed in to change notification settings - Fork 149
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
Can't figure how to make this work with seeds.ex #14
Comments
If you have an uploaded image on S3 which you want to reference directly, you should not use primary keys of the model to store the files, as these could change every time you seed. I would instead use a uuid as the filename / path. Then, during the seed file, I would set the avatar attribute directly, rather than going through an upload process. user = Repo.get! User, 1
user |> Ecto.Changeset.change(avatar: "ccfba165-aa01-4640-a2c7-a580a9a3bb4a.png?v=63620622730") |> Repo.update! Did you find a different approach to take? |
@stavro No such luck. I've just been skipping images for now. I tried your suggestion but I'm stil getting the following errors: https://gist.github.com/keslert/c93e46def689e79ca8d5. I tried inserting the book by itself and then doing the update and it gives the same error. This is my BookImage implementation: https://gist.github.com/keslert/445671bf256622319f84 |
Sorry, try this: book = Repo.get! Book, 1
book |> Ecto.Changeset.change(
image: %{file_name: "tea_rex.jpeg", updated_at: Ecto.DateTime.utc}
) |> Repo.update! |
Awesome, that did it. Thanks! |
I'm trying to populate my database with some fake data and I want it to point at a previously uploaded image, but I keep getting errors. What's the proper way to make this happen?
The text was updated successfully, but these errors were encountered: