У меня есть простой вопрос.Rails 4: как я могу объединить область из ассоциации?
У меня есть несколько моделей связанные:
class Video < ActiveRecord::Base
include ContentSharable
scope :published, -> { where(visible: true).where 'published_at <= ?', Time.zone.now }
end
class ContentShare < ActiveRecord::Base
belongs_to :sharable, polymorphic: true
scope :for_feed, -> { where.not(image: nil) }
end
Мне нужно, что ContentShare.for_feed
возвращается ко мне все записи, где image is not null
и где ассоциированная sharable
является published
. Как я могу объединить область?
Я пытался, но ContentShare является объединение Polymorfic, у меня есть "Видео", Галерея и другие классы ... –