Allyedge
# My AvatarUploader
# Override the storage directory:
def storage_dir(_version, {_file, scope}) do
"uploads/user/avatars/#{scope.id}"
end
# My User schema
use Waffle.Ecto.Schema
schema "users" do
field :avatar, Allychat.Uploaders.AvatarUploader.Type
field :email, :string
field :password, :string, virtual: true, redact: true
field :hashed_password, :string, redact: true
field :confirmed_at, :naive_datetime
timestamps()
end
def avatar_changeset(user, attrs) do
user
|> cast(attrs, [:avatar])
|> cast_attachments(attrs, [:avatar])
|> validate_required([:avatar])
end
# My Accounts context
def change_user_avatar(user, attrs \\ %{}) do
User.avatar_changeset(user, attrs)
end
def update_user_avatar(user, attrs) do
changeset =
user
|> User.avatar_changeset(attrs)
Ecto.Multi.new()
|> Ecto.Multi.update(:user, changeset)
|> Repo.transaction()
|> case do
{:ok, %{user: user}} -> {:ok, user}
{:error, :user, changeset, _} -> {:error, changeset}
end
end
When I do this, it tells me that it can’t find id in nil. I tried a lot of options, also the one from waffle_ecto docs, and still couldn’t find an answer on how to upload an image to the storage_dir.
Does anyone know what I can do to fix this? I’m pretty new to Waffle ![]()
Trending in Questions
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
Hello,
I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind.
However, when I launch mix phx.server, I get an error...
New
I really like the adapter patterns that ecto, nebulex, waffle, etc. use and would love find something similar for a key management servic...
New
Hello folks!
So at work, we are seeing some situations where we have to define some “fixed” strings that are used across the codebase in...
New
I’m working on a small exercise involving update_in/3, and I came up with this solution:
data = %{
name: "Periodic Table",
category:...
New
How Can I Optimise Compile Time Dependencies
I have been building an elixir application for about 2 years now. Many modules and files ha...
New
Is there any way to avoid the Hologram compiler running when using iex? It seems like the front-end code could potentially be disregarded...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #ai
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixirconf-us
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #security
- #metaprogramming











Showing Posts 1 to 7- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
akashv
Can you try once with removing the avatar from first cast? My working config is like below and everything else is similar, so I’m not sure what else could be the problem apart from the user being an empty map.
Allyedge
Hey, I did that and realised that my problem was in the image getting functions, not the ones that create it.
Everything works now
ambareesha7
What was the fix you did? To fix it
Me also working on some waffle related stiff
Allyedge
Hey, you can check out the changes I’ve made to fix it by reading the changes in this commit.
https://github.com/Allyedge/allychat/commit/57684a2f97ac783d2ec425d97786bb7e4fd940af
ambareesha7
I couldn’t visit the link because of authentication,
It showing 404 status when I click on the link
Allyedge
Can you try it again now?
ambareesha7
Thank you, it’s opening now