ruby on rails - if I have 2 models can I sort them both at once? -
let's have image model , video model how can display them both in index date
i going take torch here. :) sergio means this:
class media < activerecord::base belongs_to :image belongs_to :video end
then can sort/filter/paginate easily
@media = media.where('created_at > ?', 2.days.ago).order(:id)
just don't forget create corresponding media record when add new image/video
image = ... media.create(image: image)
Comments
Post a Comment