views:

45

answers:

1

Hello, rails 3 seems to escape everything, including html. I have tried using raw() but it still escapes html. Is there a workaround? This is my helper that I am using (/helpers/application_helper.rb):

module ApplicationHelper
  def good_time(status = true)
    res = ""
    if status == true
      res << "Status is true, with a long message attached..."
    else
      res << "Status is false, with another long message"
    end
  end
end

I am calling the helper in my view using this code:

<%= raw(good_time(true)) %>
+4  A: 

You can use .html_safe like this:

def good_time(status = true)
  if status
    "Status is true, with a long message attached...".html_safe
  else
    "Status is false, with another long message".html_safe
  end
end

<%= good_time(true) %>
captaintokyo
Thanks! I found out a way to fix it just after I posted the question, but this is much more elegant and simplistic.
alexy13