How do I call a Rails helper method from inside another helper method? How do I call a Rails helper method from inside another helper method? ruby ruby

How do I call a Rails helper method from inside another helper method?


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 filedef my_helper  "<div>" + someother_helper_which_generates_html + "</div>"end

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


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>"  endend

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!