rails/activerecord/test/models/uuid_entry.rb
Ryota Egusa 941c5641b0 Allow delegated_type to be specified primary_key and foreign_key
Since delegated_type assumes that the foreign_key ends with `_id`,
`singular_id` defined by it does not work when the foreign_key does
not end with `id`. This commit fixes it by taking into account
`primary_key` and `foreign_key` in the options.
2020-12-18 15:06:16 +09:00

6 lines
188 B
Ruby

# frozen_string_literal: true
class UuidEntry < ActiveRecord::Base
delegated_type :entryable, types: %w[ UuidMessage UuidComment ], primary_key: :uuid, foreign_key: :entryable_uuid
end