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

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -