AshTrans update issue

This is for @Robert Timis. I created a new project on ash HQ and added an attribute to user:
attribute :about_me, :string do
allow_nil? true
public? true
end
attribute :about_me, :string do
allow_nil? true
public? true
end
I followed the setup for translation and I have
translations do
public? true
fields [:about_me]
locales [:it]
end
translations do
public? true
fields [:about_me]
locales [:it]
end
I have
use Ash.Resource,
otp_app: :ash_trans_ai_test,
domain: AshTransAiTest.Accounts,
data_layer: AshPostgres.DataLayer,
authorizers: [Ash.Policy.Authorizer],
extensions: [AshAuthentication, AshTrans.Resource]
use Ash.Resource,
otp_app: :ash_trans_ai_test,
domain: AshTransAiTest.Accounts,
data_layer: AshPostgres.DataLayer,
authorizers: [Ash.Policy.Authorizer],
extensions: [AshAuthentication, AshTrans.Resource]
In actions I added update: defaults [:read, update: [:about_me, :translations]] but when I call it it doesn't behave as expected. I get a user. Then I create an update changeset: ch = Ash.Changeset.for_update user, :update, %{about_me: "Hello my name is Kenneth"}, translations: %{it: %{about_me: "Ciao mi chiamo Kenneth"}} but user = Ash.update! ch, authorize?: false returns
%AshTransAiTest.Accounts.User{
__meta__: #Ecto.Schema.Metadata<:loaded, "users">,
translations: nil,
id: "ce3b1fa4-acd0-42e7-bc61-9f5b0c332bbf",
email: #Ash.CiString<"admin@test.org">,
about_me: "Hello my name is Kenneth"
}
%AshTransAiTest.Accounts.User{
__meta__: #Ecto.Schema.Metadata<:loaded, "users">,
translations: nil,
id: "ce3b1fa4-acd0-42e7-bc61-9f5b0c332bbf",
email: #Ash.CiString<"admin@test.org">,
about_me: "Hello my name is Kenneth"
}
and the changeset also is missing the translation map:
#Ash.Changeset<
domain: AshTransAiTest.Accounts,
action_type: :update,
action: :update,
attributes: %{about_me: "Hello my name is Kenneth"},
relationships: %{},
errors: [],
data: %AshTransAiTest.Accounts.User{
__meta__: #Ecto.Schema.Metadata<:loaded, "users">,
translations: nil,
id: "ce3b1fa4-acd0-42e7-bc61-9f5b0c332bbf",
email: #Ash.CiString<"admin@test.org">,
about_me: "Hello, my name is Kenneth"
},
valid?: true
>
#Ash.Changeset<
domain: AshTransAiTest.Accounts,
action_type: :update,
action: :update,
attributes: %{about_me: "Hello my name is Kenneth"},
relationships: %{},
errors: [],
data: %AshTransAiTest.Accounts.User{
__meta__: #Ecto.Schema.Metadata<:loaded, "users">,
translations: nil,
id: "ce3b1fa4-acd0-42e7-bc61-9f5b0c332bbf",
email: #Ash.CiString<"admin@test.org">,
about_me: "Hello, my name is Kenneth"
},
valid?: true
>
Am I missing something? Is there a bug somwhere? 🐛 I can push this if you want but it's nothing special, I'm trying things out.
Solution:
what the hell... now it works. 👺 sorry for bothering you. I don't understand what happened. 🙇 okay, maybe because I didn't create the user with embedded structs the update didn't work 🤔 might just be that. again, sorry, my bad....
Jump to solution
2 Replies
ken-kost
ken-kostOP5mo ago
Update: I tried with create and that worked. 🤔 but update on that correct created didn't work, hmm okay, I switched to the synced fork and it worked 🤔 I'll try again with 0.1.4 version
Solution
ken-kost
ken-kost5mo ago
what the hell... now it works. 👺 sorry for bothering you. I don't understand what happened. 🙇 okay, maybe because I didn't create the user with embedded structs the update didn't work 🤔 might just be that. again, sorry, my bad.

Did you find this page helpful?