mercredi 10 mai 2017

Merge two active record using or merge in Rails 3.2, ActiveRecord 3.2

I have two different queries that I need to merge into one query (so I can use will_paginate).

After they are merged I need to group_by :date.

Then I need to apply paginate to it.

results1 = Mission.joins(:track => { :track_subscriptions => :member }).where("member_id = ?", current_member.id)
results2 = Mission.joins(:track).merge(Track.visibility_unsubscribables)
finalresults = results1.or(results2) 
finalresults.group_by { |r| r[:date] }
finalresults.paginate(:page => params[:page], :per_page => 30)

This doesn't work because I don't have ActiveRecord 5+, and I can't get will_paginate to work with grouped results.

Is there a better way to approach this?

Aucun commentaire:

Enregistrer un commentaire