In this code. I’m not an error the files are easily inserting.
But my after_save function cannot get the value in the shape of map from changeset.
However on the same spot when I call my after_Save function after Repo.insert. It does work because getting map from Repo.insert.
Here’s my output:
INSERT INTO `files` (`name`,`size`,`type`,`url`,`user_id`,`inserted_at`,`updated_at`) VALUES (?,?,?,?,?,?,?) ["tdyhf.jpg", 58118, "image/jpeg", "/uploads/b7a23917-c5de-431e-8574-dcff00e3f325.jpg", 1, ~N[2021-10-15 15:02:02], ~N[2021-10-15 15:02:02]]
[debug] QUERY OK db=0.0ms idle=47.0ms
INSERT INTO `files` (`name`,`size`,`type`,`url`,`user_id`,`inserted_at`,`updated_at`) VALUES (?,?,?,?,?,?,?) ["pd36-2-pia03654.jpg", 233077,
"image/jpeg", "/uploads/c2020c7b-77a4-47a8-9c00-07dc9d7445f2.jpg", 1, ~N[2021-10-15 15:02:02], ~N[2021-10-15 15:02:02]]
[
ok: %Initium.Files.File{
__meta__: #Ecto.Schema.Metadata<:loaded, "files">,
alt_text: nil,
caption: nil,
description: nil,
dimensions: nil,
id: 86,
inserted_at: ~N[2021-10-15 15:02:02],
name: "tdyhf.jpg",
size: 58118,
title: nil,
type: "image/jpeg",
updated_at: ~N[2021-10-15 15:02:02],
url: "/uploads/b7a23917-c5de-431e-8574-dcff00e3f325.jpg",
user: #Ecto.Association.NotLoaded<association :user is not loaded>,
user_id: 1
},
ok: %Initium.Files.File{
__meta__: #Ecto.Schema.Metadata<:loaded, "files">,
alt_text: nil,
caption: nil,
description: nil,
dimensions: nil,
id: 87,
inserted_at: ~N[2021-10-15 15:02:02],
name: "pd36-2-pia03654.jpg",
size: 233077,
title: nil,
type: "image/jpeg",
updated_at: ~N[2021-10-15 15:02:02],
url: "/uploads/c2020c7b-77a4-47a8-9c00-07dc9d7445f2.jpg",
user: #Ecto.Association.NotLoaded<association :user is not loaded>,
user_id: 1
}
]