mysql - Activerecord group/order by existing array -


my db schema

  1. user (id,name etc)
  2. video-stream (id ,userid, viewercount) - one-to-one (a user can have 1 video stream)
  3. followed_streams (userid,streamid) - many many table (a user can follow many streams , streams can followed multiple users)

my /streams url has below way sort data recieved mysql

@streams = stream.order(viewers: :desc).page(params[:page]).per_page(16) 

basically, results being sorted viewer count

i want add function sorts initial table showing followed streams first followed streams show in first result.

i have below gives me array of streamids user has followed this

@followed_streams = followed_streams.where('user_id': @user.id) 

is there way can cross-reference @followed_streams initial stream table , sort followed ids top?


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -