I would call habtm a separate ImageLink model class. Then you will get:
Project
has_many :image_links, :as => :resource
BlogPost
has_many :image_links, :as => :resource
ImageLink
belongs_to :image
belongs_to :resource, :polymorphic => true
Image:
has_many :image_links
source
share