class ApplicationController < ActionController::Base
helper :all
end
module ApplicationHelper
def use_module
### ssss
end
end
class B < ApplicationController
def efd
call_private()
end
private
def call_private()
use_module()
end
end
When I call B::efd(), an error return saying ‘use_module()’ is
undefined !!
I was wonderring why ‘helper :all’ in my application.rb is not working
at all.
Then I find that this method is depend on ‘HELPERS_DIR’ variable.
However, when I type this ‘HELPERS_DIR’ in console, it shows
‘uninitialized constant’ error.
But sometimes, we need some methods that both used in view and
controller.
Where do you suggest to put them in?
You can make controller methods available to views with helper_method,
or you could have a module that you both include in a controller and
pass to helper (which among other things adds a module to the set of
helpers a view has).
I just think that “a module that both include in a controller and a
helper” is a little bit complicated then just write that method in
helper and make controller can access it, in the case that the number
of this kind of methods is not a big one.
Emm, maybe this is not the correct ruby way of doing things.
And maybe I should re-orgnize my app structure like your suggestion.
Thank you.