在 openshift 上部署时未初始化的常量 ActionView::Helpers::ActiveModelHelper

uninitialized constant ActionView::Helpers::ActiveModelHelper when deploying on openshift

我正在尝试在 openshift 上部署我的 rails 应用程序,但出现此错误。 Phusion 乘客显示此错误: 您已经激活了 rack 1.5.2,但是您的 Gem 文件需要 rack 1.6.0。使用 bundle exec 可以解决这个问题。 (Gem::LoadError)

remote: uninitialized constant ActionView::Helpers::ActiveModelHelper
remote: /var/lib/openshift/54bc0eee5973ca3f54000153/app-root/runtime/repo/vendor
/bundle/ruby/gems/actionview-4.2.0/lib/action_view/helpers.rb:40:in `<module:Helpers>'
remote: /var/lib/openshift/54bc0eee5973ca3f54000153/app- root/runtime/repo/vendor
/bundle/ruby/gems/actionview-4.2.0/lib/action_view/helpers.rb:4:in `<module:ActionView>'
remote: /var/lib/openshift/54bc0eee5973ca3f54000153/app-root/runtime/repo/vendor
/bundle/ruby/gems/actionview-4.2.0/lib/action_view/helpers.rb:3:in `<top (required)>'
remote: /var/lib/openshift/54bc0eee5973ca3f54000153/app-root/runtime/repo/vendor
/bundle/ruby/gems/actionview-4.2.0/lib/action_view/base.rb:5:in `<top (required)>'
remote: /var/lib/openshift/54bc0eee5973ca3f54000153/app-root/runtime/repo/vendor
/bundle/ruby/gems/actionview-4.2.0/lib/action_view/view_paths.rb:1:in `<top (required)>'
remote: /var/lib/openshift/54bc0eee5973ca3f54000153/app-root/runtime/repo/vendor
/bundle/ruby/gems/actionpack-4.2.0/lib/abstract_controller/rendering.rb:4:in `<top (required)>'
remote: /var/lib/openshift/54bc0eee5973ca3f54000153/app-root/runtime/repo/vendor
/bundle/ruby/gems/actionpack-4.2.0/lib/action_controller/base.rb:204:in `<class:Base>'
remote: /var/lib/openshift/54bc0eee5973ca3f54000153/app-root/runtime/repo/vendor
/bundle/ruby/gems/actionpack-4.2.0/lib/action_controller/base.rb:164:in `<module:ActionController>'
remote: /var/lib/openshift/54bc0eee5973ca3f54000153/app-root/runtime/repo/vendor
/bundle/ruby/gems/actionpack-4.2.0/lib/action_controller/base.rb:5:in `<top (required)>'
remote: /var/lib/openshift/54bc0eee5973ca3f54000153/app-root/runtime/repo/vendor
/bundle/ruby/gems/responders-2.0.2/lib/responders/controller_method.rb:37:in `<top (required)>'
remote: /var/lib/openshift/54bc0eee5973ca3f54000153/app-root/runtime/repo/vendor
/bundle/ruby/gems/responders-2.0.2/lib/responders.rb:15:in `<module:Responders>'
remote: /var/lib/openshift/54bc0eee5973ca3f54000153/app-root/runtime/repo/vendor
/bundle/ruby/gems/responders-2.0.2/lib/responders.rb:9:in `<top (required)>'
remote: /var/lib/openshift/54bc0eee5973ca3f54000153/app-root/runtime/repo/vendor
/bundle/ruby/gems/devise-3.4.1/lib/devise.rb:7:in `<top (required)>'
remote: /opt/rh/ror40/root/usr/share/gems/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
remote: /opt/rh/ror40/root/usr/share/gems/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
remote: /opt/rh/ror40/root/usr/share/gems/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
remote: /opt/rh/ror40/root/usr/share/gems/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require'
remote: /opt/rh/ror40/root/usr/share/gems/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
remote: /opt/rh/ror40/root/usr/share/gems/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
 remote: /opt/rh/ror40/root/usr/share/gems/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
 remote: /var/lib/openshift/54bc0eee5973ca3f54000153/app-root/runtime/repo/config/application.rb:9:in `<top (required)>'
 remote: /var/lib/openshift/54bc0eee5973ca3f54000153/app-root/runtime/repo/Rakefile:4:in `require'
remote: /var/lib/openshift/54bc0eee5973ca3f54000153/app-root/runtime/repo/Rakefile:4:in `<top (required)>'
remote: (See full trace by running task with --trace)
remote: Compilation of assets is disabled or assets not detected.
remote: Starting Ruby cartridge
remote: -------------------------
remote: Git Post-Receive Result: success
remote: Activation status: success
remote: Deployment completed with status: success
To ssh://54bc0eee5973ca3f54000153@livechat-rdemidovapps.rhcloud.com/~/git/livechat.git/

actionpack 4.2 需要机架 ~> 1.6.0。您的 Gemfile 可能不包含 rack gem。您可以尝试将此行添加到您的 Gemfile

gem 'rack', '~> 1.6.0'

然后 运行

bundle install  

git push origin

这可能会强制 openshift 环境使用最新的机架 gem。

OpenShift 内部依赖于 RHEL 6.6 SCL ror40,其中包括 rack 版本 1.5.2 和 passenger 4.0.18。不幸的是 none 今天无法更新。

作为开始故障排除步骤重命名 Gemfile.lock(或删除它)然后重新安装您的包 bundle install