为什么在多态关联中没有外键,例如下面表示为Rails模型的外键?
class Comment < ActiveRecord::Base belongs_to :commentable, :polymorphic => trueendclass Article < ActiveRecord::Base has_many :comments, :as => :commentableendclass Photo < ActiveRecord::Base has_many :comments, :as => :commentable #...endclass Event < ActiveRecord::Base has_many :comments, :as => :commentableend
三国纷争
相关分类