【发布时间】:2016-01-19 03:58:07
【问题描述】:
Rails 4.2.4、Ruby 2.1.7
我在 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 逻辑时,
class UserfeedController < ApplicationController
include BLL
before_action :authenticate_user!
def show
# some logic
end
end
在我的 config/application.rb 中
config.autoload_paths << Rails.root.join('lib')
这在本地运行良好,但是,当我在 Heroku 上部署它时它会中断。
它在扔
ActionController::RoutingError(未初始化常量 UserfeedController::BLL):
错误。
2015-10-20T13:45:13.791457+00:00 app[web.1]: /app/app/controllers/api/v1/userfeed_controller.rb:1:in `<top (required)>': uninitialized constant Bll (NameError)
2015-10-20T13:45:13.791457+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/engine.rb:472:in `block (2 levels) in eager_load!'
2015-10-20T13:45:13.791458+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/engine.rb:471:in `each'
2015-10-20T13:45:13.791459+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/engine.rb:471:in `block in eager_load!'
2015-10-20T13:45:13.791460+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/engine.rb:469:in `each'
2015-10-20T13:45:13.791462+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/engine.rb:469:in `eager_load!'
2015-10-20T13:45:13.791463+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/engine.rb:346:in `eager_load!'
有什么建议吗?
【问题讨论】:
-
尝试将文件夹重命名为小写(
BLL⇒bll)和(不太可能,前者应该有帮助)include ::BLL。 -
是的,我就是这样。小脑球
-
查看我的最新回答;可能这会对你有所帮助
标签: ruby-on-rails ruby heroku