1

Does anyone know how to include content_tag in helpers? I tried including ActionView::Helpers::TagHelper.

Dan Grahn
  • 9,044
  • 4
  • 37
  • 74
  • This may help .. http://apidock.com/rails/ActionView/Helpers/TagHelper/content_tag – sp1rs Feb 28 '14 at 18:58
  • The `content_tag` method should be available in your `ApplicationHelper` "out of the box" - are you getting some error when you try to call it in your `ApplicationHelper`? – CDub Feb 28 '14 at 19:17

1 Answers1

1

You should be able to do this:

module ApplicationHelper
  def something(place, url)
    content_tag :li do
      link_to(place, url)
    end
  end
 end

Let me know if that works or if you still have problems.

Mike Riley

Mike Riley
  • 282
  • 3
  • 20
  • Ok! I figured it out. The content_tag method works when the helper name matches the controller exactly. Otherwise, it doesn't. Don't ask me why we have helpers that aren't matched to controllers. I did not write them. – Dan Grahn Mar 03 '14 at 14:25