开发者

Rails 3 Unescaping Helper Output

I have a helper method that calls two other helper methods, the problem is that when I call it, the view outputs the escaped HTML. I want the actual HTML to be interpreted.

myhelper.rb

  def combined(klass)
    content_tag :span, "#{first(klass)} first : #{second(klass)} second"
  end

  def first(klass)
      content_tag :span, 
                  link_to("first", first_path(klass))
  end


  def second(klass)
       content_tag  :span, 
                  link_to("second", second_path(klass))
  end

In my view I call <%= combined(myclass)开发者_如何学JAVA %>


This works:

  def combined(klass)
    content_tag :span, "#{first(klass)} first : #{second(klass)} second".html_safe
  end

Was hoping for a more convenient way.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜