webster
webster

Reputation: 4012

Is it possible to invoke a helper_method from another Helper?

I have two Helpers, ExamsHelper and ResultsHelper

exams_helper.rb

module ExamsHelper
  def get_data
    ...
  end
end

results_helper.rb

module ResultsHelper
  def find_result
    ...
  end
end

Is it possible to access the get_data method in ResultsHelper.

I know that if I am declaring it on the ApplicationHelper, I can access it. Is there any other solution for it?

Upvotes: 0

Views: 515

Answers (1)

Marek Lipka
Marek Lipka

Reputation: 51151

You can always use include:

module ResultsHelper
  include ExamsHelper

  def find_result
    get_data # works
  end
end

Upvotes: 3

Related Questions