(no title)
joshprice | 9 months ago
When you define a relationship like `has_many :representatives`, Ash does’t create `representative_id` on the destination resource, we only validate that it exists and meets some criteria.
No resource ever modifies another resource, so you have to define the id on the other side using `belongs_to` which modifies it's own resource only adding the `respresentative_id` attribute with this
`belongs_to :representative, Representative`
If you need custom field names, you can override them:
`has_many :representatives, MyApp.Representative, destination_attribute: :custom_reference_id`
The docs explain more:
Squeeeez|9 months ago