Don't escape html in ruby on rails

后端 未结 2 1488
有刺的猬
有刺的猬 2020-12-08 06:15

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

2条回答
  •  臣服心动
    2020-12-08 07:09

    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) %>
    

提交回复
热议问题