2015-10-18 33 views
0

Rails的4.2.4,紅寶石2.1.7的ActionController :: RoutingError(未初始化常數UserfeedController :: BLL):

我有lib /目錄內的模塊。

的lib/BLL/user_feed.rb

module BLL 
class UserFeed 

    def initialize 
     logger.debug "Class has been initialized" 
    end 

    def get_user_feed(user_id) 
     # logic here 

     return { 
     # object 
     } 
    end 
end 
end 

當我嘗試包括在我的控制器使用我的user_Feed邏輯,

它拋出

的ActionController :: RoutingError(未初始化常量UserfeedController :: BLL):

錯誤。

我不確定有什麼問題。鋼軌

class UserfeedController < ApplicationController 
    include BLL 

before_action :authenticate_user! 

    def show 
    # some logic 
    end 
end 
+0

回報詞典:與包括lib夾入loadpath以下內容添加到您的config/application.rb。 – Harish

+0

我認爲在撰寫這篇文章時會有額外的結果。編輯它並使其正確無誤,返回不在課程級別,它在方法級別 – Harish

+0

您是否知道Rails不在其加載路徑中包含'lib'文件夾?你有沒有在你的'config/application.rb'中加入'config.autoload_paths << Rails.root.join('lib')'? – spickermann

回答

0

決不版本不包括lib文件夾爲每默認應用程序的loadpath。與我從數據庫中獲取了

config.autoload_paths << Rails.root.join('lib') 
+0

,我再次得到相同的錯誤。我是否應該將其添加到任何環境配置文件中? – Harish

相關問題