1
4

2 回答 2

6

You cannot mark an array HTML safe. You need to mark each element within the array as HTML-safe.

Try

array.map(&:html_safe)

Update

Sorry, I didn't look closely enough at how you are building the array. I thought it was a flat array of strings, in which case array.map(&:html_safe) would have been fine. Instead, you have to do the same for each sub-array of strings:

array.map { |e| e.map(&:html_safe) }
于 2013-09-17T21:09:08.813 回答
0

You could make the options array with actual symbols, rails helper will code it in html for you.

def options
  array = []
  array << ["$", "some value"]
  array << ["€", "some value"]
end
于 2013-09-17T22:20:11.843 回答