You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to implement a 1:1 relationship between two tables without duplicating data in a new column. The issue is that has_one does not allow specifying a custom foreign_key, while belongs_to does.
This means a new column is created which contains a set of ids, even though I only want a 1:1 relationship.
The only solution I came up with is to use belongs_to on both ends. Is this intended?
Example:
# models/registrationclassRegistrationincludeDynamoid::Documenttablename: EnvConfig.DYNAMO_REGISTRATIONS_TABLE,capacity_mode: nil,key: :attendee_id# does not workhas_one:history,class: RegistrationHistory,foreign_key: :attendee_id# works, but is semantically incorrectbelongs_to:history,class: RegistrationHistory,foreign_key: :attendee_idend# models/registration_historyclassRegistrationHistoryincludeDynamoid::Documenttablename: EnvConfig.REGISTRATION_HISTORY_DYNAMO_TABLE,capacity_mode: nil,key: :attendee_id# worksbelongs_to:registration,foreign_key: :attendee_idend
The text was updated successfully, but these errors were encountered:
I'm trying to implement a 1:1 relationship between two tables without duplicating data in a new column. The issue is that
has_one
does not allow specifying a customforeign_key
, whilebelongs_to
does.This means a new column is created which contains a set of ids, even though I only want a 1:1 relationship.
The only solution I came up with is to use belongs_to on both ends. Is this intended?
Example:
The text was updated successfully, but these errors were encountered: