gpt4 book ai didi

ruby-on-rails - Heroku ActionController::RoutingError(未初始化常量错误)

转载 作者:太空宇宙 更新时间:2023-11-03 16:45:46 25 4
gpt4 key购买 nike

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

当我尝试将其包含在我的 Controller 中以使用我的 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 上时它会中断。

它正在 throw

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

有什么建议吗?

enter image description here

最佳答案

我认为您缺少 module BLL;在 lib/bll.rb

中结束

但是,尝试将模块命名为 Bll,但我认为不是这样

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com