I’m getting a NoMethodError when trying to access a method defined in one of my helper modules from one of my controller classes. My Rails application uses the helper class method with the :all symbol as shown below:
class ApplicationController < ActionController::Base helper :all . . end
My understanding is that this should make all of my controller classes automatically include all of the helper modules within the app/helpers directory, therefore mixing in all of the methods into the controllers. Is this correct?
If I explicitly include the helper module within the controller then everything works correctly.
helper :allmakes all the helpers (yes, all of them) available in the views, it does not include them into the controller.If you wish to share some code between helper and controller, which is not very desirable because helper is UI code and controller is, well, controller code, you can either include the helper in the controller, or create a separate module and include that in the controller and the helper as well.