Multiple rails with the same method name

I have two different helper files (photos_helper and comments_helper) that have a method named actions_for. How can I explicitly indicate which helper method I need? I know that I can simply rename one of them, but I would prefer to leave them the same. I tried PhotosHelper::actions_for, but it does not work.

+5
source share
2 answers

In Rails 3, all helpers are always (Rails 3.1 has a patch to selectively enable helpers). What happens behind the scenes:

class YourView
  include ApplicationHelper
  include UserHelper
  include ProjectHelper

  ...
end

, , Rails, actions_for. .

ProjectHelper.action_for, project_action_for - .

+7

Class Method

module LoginsHelper
  def self.your_method_name
    "LoginsHelper"
  end
end

module UsersHelper
  def self.your_method_name
    "UsersHelper"
  end
end

   LoginsHelper.your_method_name #Gives 'LoginsHelper'

   UsersHelper.your_method_name #Gives 'UsersHelper'
+6

All Articles