STI and polymorphs

前端 未结 5 1381
孤独总比滥情好
孤独总比滥情好 2021-01-04 13:53

I have problem with my code

class Post < ActiveRecord::Base
end

class NewsArticle < Post
  has_many :comments, :as => :commentable, :dependent =>         


        
5条回答
  •  轮回少年
    2021-01-04 14:37

    def commentable_type=(sType) super(sType.to_s.classify.constantize.base_class.to_s) end

    This method is returning class as Post, what to do if you want to store the inherited class Post as commentable_type?

提交回复
热议问题