Along came Poly - with the wrong type though
Published about 7 years ago

I wish we could do

class Attachment < ActiveRecord::Base
  belongs_to :attachable, :polymorphic => :true
  validates_presence_of :width, :height, :if => Proc.new { |attachment| ["Photo", "Logo"].include? attachment.attachable_type }
end

class Asset < ActiveRecord::Base
  has_one :attachment, :as => :attachable
end

class Photo < Asset
end

class Logo < Asset
end

class Video < Asset
end

But we can’t