Instead this worked. Not sure exactly why the other works and not
select.
athlete.leagues.collect(&:league_id)
because “.select” returns only those elements that return true to an
evaluation, while “.collect” returns the result of the block passed to
every element. Have a look at the Enumerable and Array api pages.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.