Polymorphic FK mapped to field other than ID

Here’s the scenario:

I have a table that looks something like:

containers

id
name
external_id
created_ts

and another for tracking like:

trackings

id
created_ts
event
trackable_id
trackable_type

My containers table (along with a few others) has a polymorphic
relationship to trackings. Normally, trackings would map to
containers by the container’s ‘id’, but I want to see if I can have it
reference containers by the external_id, which comes from an external
application after the record is created and will be unique.

Is this possible?

Thanks in advance for any info.

Jon

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs