Reputation: 3522
i have the following code which is meant to be looping over an array, with a comma after each object expect the last idea
-if is_manager(team)
- is_manager(team).map(&:fullname).each.join(',') do |name|
= "#{name}"
it appears that the code is trying to be executed, but for some reason the .join element is causing it to error like below
undefined method `join' for #<Enumerator: ["Tom Garcia", "Paul McGuane"]:each>
what do i need to do, to have this working?
Upvotes: 0
Views: 138
Reputation: 96454
-if is_manager(team)
= is_manager(team).map(&:fullname).join(',')
Upvotes: 1
Reputation: 4471
Get rid of the "each" piece; join is to be called on an array directly and should return a string.
Meaning the following should suffice:
is_manager(team).map(&:fullname).join(',')
Edit: Seems you're using HAML, so you need the '=' for output, try the following:
-if is_manager(team)
= is_manager(team).map(&:fullname).join(',')
Upvotes: 1