I'm trying to make a query that, I believe, is a double joins call.
@customer.jobs.joins(:assignments).where('assignments.employee_id' => current_user.id).collect{|j|j.payments}.flatten
I'm looking for payments, only if they've been assigned to my current_user under my customer record.
Payments are connected to customers through a joins table ( payment_applications
). Employees are assigned to Jobs through a join table ( assignments
).
The query above returns the right objects, but its an array so I can't assign them to pagination. How can I keep that query an ActiveRecord call?