Go back Rails ActiveRecord

has_many/has_one belong_to when key names are not self explanatory



# table: foobar_oauth_connections
# id: int
# source_key: string
class Foobar::OauthConnection < ApplicationRecord
  belongs_to :website, foreign_key: "source_key", primary_key: "domain", optional: true
end

# table: website
# id: int
# domain: string
Class Website < ApplicationRecord
  has_one :foobar_oauth_connection, :class_name => 'Foobar::OauthConnection', foreign_key: "source_key", primary_key: "domain"
end