Rails Filter records of child model based upon the parent model attribute

强颜欢笑 提交于 2019-12-04 19:13:34

Just add this to your Upload model:

named_scope :with_published_foto_gossip, :joins => :foto_gossip, :conditions => "foto_gossips.published_at IS NOT NULL"

then you can get all the uploads with published foto_gossip like this:

Upload.with_published_foto_gossip 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!