Postgresql 未为多态关联设置imageable type
我的rails 4.2应用程序中有两个模型Postgresql 未为多态关联设置imageable type,postgresql,ruby-on-rails-4,activerecord,Postgresql,Ruby On Rails 4,Activerecord,我的rails 4.2应用程序中有两个模型 class LandingPage < ActiveRecord::Base has_one :section2_photo, -> { where imageable_type: "Section2Photo"}, class_name: Image, foreign_key: :imageable_id, foreign_type: :imageable_type, dependent: :destroy, as: :im
class LandingPage < ActiveRecord::Base
has_one :section2_photo, -> { where imageable_type: "Section2Photo"},
class_name: Image, foreign_key: :imageable_id, foreign_type: :imageable_type, dependent: :destroy, as: :imageable
has_one :section3_photo, -> { where imageable_type: "Section3Photo"},
class_name: Image, foreign_key: :imageable_id, foreign_type: :imageable_type, dependent: :destroy, as: :imageable
end
但当我这么做的时候
image.imageable_type
我明白了
而不是
"Section2Photo"
只是为我删除的其他人发帖
as: :imageable
现在工作很好
"LandingPage"
"Section2Photo"
as: :imageable