Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.56 KB | None | 0 0
  1.     def groups_user
  2.         @groups = PaidGroup.all
  3.  
  4.         @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}")
  5.         @paying = @paying.reverse
  6.         @array = []
  7.         @paying.each do |el|
  8.             if not @array.include?(el)
  9.                 @array.push(el)
  10.             end
  11.         end
  12.         @array = @array.reverse
  13.  
  14.  
  15.         @my_gr = []
  16.         @groups.each do |el|
  17.             i = @array.index(el)
  18.             if i
  19.                 @my_gr.push(@array[i])
  20.             else
  21.                 @my_gr.push(el)
  22.             end
  23.         end
  24.  
  25.  
  26.         render json: @my_gr, status: :ok
  27.     end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement