Guest User

Untitled

a guest
Dec 3rd, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. # controller for group/customers
  2. def index
  3. @customers = current_user.available_customers(param[:group_id].to_i)
  4. end
  5.  
  6. # user
  7. def available_customers(group_id)
  8. # some other code, that sometimes returns early
  9.  
  10. # this is the line of failure
  11. # self.accessible_group_ids returns an array of integers
  12. # as does Group.children_ids
  13. # This line is attempting to get the subset of group ids that the user
  14. # is *allowed* to touch, and the hierarchy of group ids under the selected one.
  15. ids = (self.accessible_group_ids & ([group_id] + Group.children_ids(group_id)))
  16. return Customer.where(group_id: ids)
  17. end
  18.  
  19. def available_customers(group_id)
  20. # nil handling
  21. group_id = group_id.to_i
  22. # everything else
  23. end
Add Comment
Please, Sign In to add comment