Rails, Why does this helper not output HTML, but rather HTML in quotes? -
i have following helper in application_helper.rb file:
def topmenu pages = { "projects" => projects_path, "photos" => photos_path } pages.map |key, value| classnames = %( class="current") if controller.controller_name == key "<li#{classnames}>#{link_to(key, value)}</li>" end end
then in application.html.erb file have:
<%= topmenu %>
for reason, page generating showing html above helper text, not html. not sure why? thx
i presume you're running rails3. add .html_safe
method call before returning string:
"<li#{classnames}>#{link_to(key, value)}</li>".html_safe
Comments
Post a Comment