我希望cloudfoundry的vcap-service-base可以访问cloud_controller的数据库,然后我需要在vcap-service-base中的provisioner.rb来要求'active_record'。 所以我在vcap-service-base的Gemfile中添加了“gem”activerecord“”,然后运行'bundle install'。 在provisioner.rb中,我添加了“require'active_record'”,在启动cloudfoundry时,它总是抛出一个错误:在`require'中:没有这样的文件加载 - active_record(LoadError),如下所示:
/root/cloudfoundry/.deployments/devbox/deploy/rubies/ruby-1.9.2-p180/lib/ruby/gems/1.9.1/bundler/gems/vcap-services-base-1077d35ef73b/lib/base/provisioner.rb:9:in `require': no such file to load -- active_record (LoadError)
from /root/cloudfoundry/.deployments/devbox/deploy/rubies/ruby-1.9.2-p180/lib/ruby/gems/1.9.1/bundler/gems/vcap-services-base-1077d35ef73b/lib/base/provisioner.rb:9:in `<top (required)>'
from /root/cloudfoundry/.deployments/devbox/deploy/rubies/ruby-1.9.2-p180/lib/ruby/gems/1.9.1/bundler/gems/vcap-services-base-1077d35ef73b/lib/vcap_services_base.rb:4:in `require'
from /root/cloudfoundry/.deployments/devbox/deploy/rubies/ruby-1.9.2-p180/lib/ruby/gems/1.9.1/bundler/gems/vcap-services-base-1077d35ef73b/lib/vcap_services_base.rb:4:in `<top (required)>'
from /root/cloudfoundry/vcap/bin/../services/mysql/bin/mysql_node:7:in `require'
from /root/cloudfoundry/vcap/bin/../services/mysql/bin/mysql_node:7:in `<main>'
根据错误,它是LoadError。 但是当我在/root/cloudfoundry/.deployments/devbox/deploy/rubies/ruby-1.9.2-p180/lib/ruby/gems/1.9.1/gems中搜索了gem“active_record”时,它就在那里。 现在我很困惑它是LoadError还是我错过了一些重要的东西。 为什么在vcap-service-base中,找不到“require'active_record'”?
答案 0 :(得分:0)
在云代工厂部署任何rails-3应用时,我们需要遵循以下步骤。
如果在应用内部使用了任何宝石,他们应该捆绑包,然后再次捆绑安装。
在config/environments/production.rb
文件中,修改
config.serve_static_assets = false
到
config.serve_static_assets = true
使用以下命令预编译资产
bundle exec rake assets:precompile
按照以下命令将应用推送到 vmc 。
vmc push --runtime ruby19