Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def groups_user
- @groups = PaidGroup.all
- @paying = PaidGroup.select('user_payings.*, paid_groups.*').joins("LEFT JOIN user_payings ON user_payings.paid_group_id = paid_groups.id WHERE user_id=#{@auth_user.id}")
- @paying = @paying.reverse
- @array = []
- @paying.each do |el|
- if not @array.include?(el)
- @array.push(el)
- end
- end
- @array = @array.reverse
- @my_gr = []
- @groups.each do |el|
- i = @array.index(el)
- if i
- @my_gr.push(@array[i])
- else
- @my_gr.push(el)
- end
- end
- render json: @my_gr, status: :ok
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement