Rails 3 - raw/html_safe not working in some cases?
- by Frexuz
I'm having difficulties with output not being encoded even though I'm using raw or html_safe.
This one is writing out the   in my final HTLM page.
def build_tag_cloud(tag_cloud, style_list)
tag_cloud.sort!{ |x,y| x.permalink <=> y.permalink }
max, min = 0, 0
tag_cloud.each do |tag|
max = tag.followers.to_i if tag.followers.to_i > max
min = tag.followers.to_i if tag.followers.to_i < min
end
divisor = ((max - min) / style_list.size) + 1
html = ""
tag_cloud.each do |tag|
name = raw(tag.name.gsub('&','&').gsub(' ',' '))
link = raw(link_to "#{name}", {:controller => "/shows", :action => "show", :permalink => tag.permalink}, :class => "#{style_list[(tag.followers.to_i - min) / divisor]}")
html += raw("<li>#{link}</li> ")
end
return raw(html.to_s)
end
What is allowed in using raw and html_safe? And how should my example above be fixed?