her
her copied to clipboard
has_many build does not use declared foreign_key
this line: https://github.com/remiprev/her/blob/master/lib/her/model/associations/has_many_association.rb#L55
shouldn't that be checking if a foreign_key is declared on the association? and if so then use that key/attribute?
we use UUID for our external keys, the internal id attribute would never be known to the caller client, but for this line of code we need to do explicit passing of the foreign_key
e.g.
new_symptom = appointment.symptoms.build(symptom_guid: SecureRandom.uuid, _scheduled_event_guid: a.scheduled_event_guid )
=> #<Symptom(appointments/61CFE46B-69BC-4DCB-AC96-789E69E68CD5/symptoms) symptom_guid="ff012c51-d2c3-440f-9a67-2673375bc686" _scheduled_event_guid="61CFE46B-69BC-4DCB-AC96-789E69E68CD5" appointment_id="61CFE46B-69BC-4DCB-AC96-789E69E68CD5">
as you can see, there is the injected 'appointment_id' value which is meaningless in addition the uuid for the parent object needs to be explicitly passed
… or maybe I'm doing it wrong ...