Ich verwende Rails 4.2.3. statt nur Rendering Ich habe dies in meiner app/Helfer/admin_helper.rb Datei ...Wie verhindere ich, dass meine HTML-Tags maskiert werden?
module AdminHelper
def menu_builder(page_id)
tabs = ['Current Objects','Add New Object','Approve Objects']
content = ""
tabs.each do |tab|
content << if page_id == tab
content_tag('li', content_tag('a', tab, :href => nil), :class => 'current') + " "
else
content_tag('li', content_tag('a', tab, :href => "/#{tab}")) + " "
end
end
content
end
end
aber meiner Meinung nach, wenn ich die Methode
<h1>Admin#index</h1>
<ul>
<%= menu_builder(@page_id) %>
</ul>
Die HTML aufrufen als Tags entkommen ist. Das heißt, wenn ich Quelle zu sehen, das ist, was ich auf meiner Seite ...
<ul>
<li><a href="/Current Objects">Current Objects</a></li> <li><a href="/Add New Object">Add New Object</a></li> <li><a href="/Approve Objects">Approve Objects</a></li>
</ul>
Was muss ich tun, damit meine Seite korrekt dargestellt wird?
Rufen Sie '.html_safe' auf' content' auf. –
Mögliches Duplikat von [HTML nicht entgehen in Ruby on Rails] (http://stackoverflow.com/questions/3932267/dont-escape-html-in-ruby-on-rails) –