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
回報詞典:與包括
lib
夾入loadpath以下內容添加到您的config/application.rb
。 – Harish我認爲在撰寫這篇文章時會有額外的結果。編輯它並使其正確無誤,返回不在課程級別,它在方法級別 – Harish
您是否知道Rails不在其加載路徑中包含'lib'文件夾?你有沒有在你的'config/application.rb'中加入'config.autoload_paths << Rails.root.join('lib')'? – spickermann