I may be totally wrong, but I don't  see the "result" variable being used inside the block so what gets returned is the last element. My guess is you want a list of relevant package_group_ids not just last element in the package group rules.
```ruby
[1, 2, 3, 9].inject([]) { |result, element|  element } # => returns 9
```
what you probably want is

```ruby
[1, 2, 3, 9].inject([]) { |result, element|  result + [element] } # => returns [1,2,3,9] 
```