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

Popular posts from this blog

drupal - using views argument in the view tpl.php file -

php - Posting PHPBB Forum Thread/Post info in a website -

php - Add a blog by sending a mail to a certain emailadress -