简体   繁体   中英

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?

You can always use include :

module ResultsHelper
  include ExamsHelper

  def find_result
    get_data # works
  end
end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM