为什么在多态关联中没有外键,例如下面表示为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
- 3 回答
- 0 关注
- 819 浏览
添加回答
举报
0/150
提交
取消