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

当我试图将其包含在控制器中以使用用户馈送逻辑时,
 class UserfeedController < ApplicationController
  include BLL

 before_action :authenticate_user!

  def show
   # some logic
  end
end

在my 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!'

有什么建议吗?
ruby-on-rails - Heroku ActionController::RoutingError(未初始化的常量错误)-LMLPHP

最佳答案

我想你漏掉了一个
但是,也可以给模块命名,但我认为不是这样的

关于ruby-on-rails - Heroku ActionController::RoutingError(未初始化的常量错误),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33237545/

10-12 19:09