views:

46

answers:

3

I am writing a helper that needs to call another helper, which generates html. How do I do that?

+1  A: 

Just call it.

If it is in a different helper file, your controller can include the other helpfile by using the controller method "helper"

Added:

Here is an example:

# in the view
<%= my_helper %>

# in the helper file
def my_helper
  "<div>" + someother_helper_which_generates_html + "</div>"
end

** Please add more details to your question if this isn't helping....

Larry K
A: 

try:
include AnotherHelper

psjscs
A: 

Something like this should help you (say, in application_helper.rb)

module ApplicationHelper

  def create_div
    html("this is some content")
  end

  def html(content)
    "<div>#{content}</div>"
  end

end

In this case, the create_div method is calling the html method with a string as an argument. the html method returns a string of HTML with the argument you supply embedded. in a view, it would look like:

<%= create_div %>

hope this helps!

Brian