class Keywordable < ApplicationRecord belongs_to :keyword belongs_to :keywordable, polymorphic: true end class Keyword < ApplicationRecord has_many :keywordables end