set user_id field with actor id during create action

I have a resource that has the following relationship:
relationships do
belongs_to :user, Accounts.User do
allow_nil? false
end
end
relationships do
belongs_to :user, Accounts.User do
allow_nil? false
end
end
I want to create a create action that will create a new instance of that resource but without having to send the user_id with the resources params, I want to get it directly from the current actor, is there command to do that without a manual action?
2 Replies
ZachDaniel
ZachDaniel3y ago
The way you’d do it yourself is with a “change”. (Most custom things can be done that way) But there is a built in change that wil do that for you.
create :create do
change relate_actor(:user)
end
create :create do
change relate_actor(:user)
end
Blibs
BlibsOP3y ago
Thank you, worked like a charm

Did you find this page helpful?