demo how to use polymorphic with has_many through at both side
rails 4.0.0
ruby 1.9.3
classArticle < ActiveRecord::Basehas_many:attachable_entities,as: :entityhas_many:attachables,through: :attachable_entities,source: :attachable,source_type: ImageendclassAttachableEntity < ActiveRecord::Basebelongs_to:entity,polymorphic: truebelongs_to:attachable,polymorphic: trueendclassImage < ActiveRecord::Basehas_many:attachable_entities,as: :attachablehas_many:entities,through: :attachable_entities,source: :entity,source_type: Articleend