When using objects returned by an ActiveRecord proxy using a loop, if that is fine in the view, but sometimes I want to turn only one of the common hash attributes into an array. I find that I am doing this a lot, which leads to looking somewhat verbose:
forum_roles = []
@forum
@forum.each do |role|
forum_roles << role.name
end
forum_roles
Just wondering if there is an easier way to get to ['a','b']
source
share