Use of managed_relationship not clear

I am trying to create an action that will create a Supplier and populate the 2 belongs_to relationships it has. I have tried a default create action with the id fields populated, but they do not get set. I have tried manage_relationship with both ids as action arguments and with records as arguments.
The most recent attempt: create :new do argument :company, :uuid do allow_nil? false end argument :account, :uuid do allow_nil? false end change manage_relationship(:company, type: :append_and_remove) change manage_relationship(:account, type: :append_and_remove) end
3 Replies
Alan Heywood
Alan Heywood2y ago
Since you're setting the records directly, your arguments should be :map instead of :uuid If you want to set by id, it would be something like:
create :new do
argument :company_id, :uuid do
allow_nil? false
end
argument :account_id, :uuid do
allow_nil? false
end

change manage_relationship(:company_id, :company, type: :append_and_remove)
change manage_relationship(:account_id, :account, type: :append_and_remove)
end
create :new do
argument :company_id, :uuid do
allow_nil? false
end
argument :account_id, :uuid do
allow_nil? false
end

change manage_relationship(:company_id, :company, type: :append_and_remove)
change manage_relationship(:account_id, :account, type: :append_and_remove)
end
ZachDaniel
ZachDaniel2y ago
You can set attribute_writable? true on the belongs to relationships
TechnoMage
TechnoMageOP2y ago
thank you.

Did you find this page helpful?