I have an object named Puzzle and I’m calling .map on it in order to isolate the ‘title’ values. I then use ‘puts’ in order to print them neatly but nothing is returned.
def puzzle_find
title_array = self.puzzles.map { |s| s.title }
puts title_array
end
#=> " "
If I don’t use ‘puts’ then I get the array like this:
def puzzle_find
title_array = self.puzzles.map { |s| s.title }
end
#=> ["title 1", "title 2", "title 3"]
I’m trying to make the output look like this in my view:
title 1
title 2
title 3
thanks
The collection of titles should be prepared in the controller (or exposed by the controller and retrieved in the model, or etc., as long as there’s a collection of titles at the end of it all):
View:
(Or wrap it up in a partial, or use a helper. Above assumes scrubbed of HTML badness.)