Rails HABTM with polymorphic relationships
问题 I have a table Category which can have many Businesses and Posts . And a Business / Post can have many Categories so I created a polymorphic tabled called CategoryRelationship to break up the many to many relationship. Business model has these relationships: has_many :categories, through: :category_relationships, :source => :category_relationshipable, :source_type => 'Business' has_many :category_relationships CategoryRelationship model has these relationships: attr_accessible :category_id,