2016-09-27 64 views
0

我在控制器中有一些辅助方法和私有方法,我想在另一个控制器中使用相同的辅助方法和私有方法。所以我将该代码移到了模块中,并尝试将模块包含在第二个控制器中。但我似乎无法做到这一点,因为它说DashboardHelper的未定义方法助手方法。无论如何要完成我想要做的事情吗?如何将辅助方法和私有方法放在帮助器中

这里是你的代码必须包括在您的关心extend ActiveSupport::Concern

module DashboardHelper 
    def get_date(log) 

    end 


    def get_working_hours(log) 

    end 


    helper_method :get_date, :get_working_hours 


    private 
    def employee_params 

    end 

    def identify_employee 

    end 

    def check_is_arrived 

    end 

    def calculate_time_percentage 

    end 


end 

class AccountController < ApplicationController 
    include DashboardHelper 
end 

回答

0

你好门。 这不应该是你的帮手文件夹而不是在你关注的文件夹的地方把它

末文件可能看起来像

module DashboardHelper 
    extend ActiveSupport::Concern 
    module ClassMethods 
    def get_date(log) 
    end 


    def get_working_hours(log) 
    end 

    helper_method :get_date, :get_working_hours 

    private 
    def employee_params 

    end 

    def identify_employee 
    end 

    def check_is_arrived 
    end 

    def calculate_time_percentage 
    end 

    end 
end