1

我希望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时,总是报错:in `require': no such file to load -- 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'”?

4

1 回答 1

0

在 Cloud Foundry 上部署任何 rails-3 应用程序时,我们需要遵循以下步骤。

  1. 如果在应用程序中使用了任何 gem,他们应该执行bundle package然后再次执行bundle install

  2. config/environments/production.rb文件中,修改行

    config.serve_static_assets = false 
    

    config.serve_static_assets = true
    
  3. 使用以下命令预编译资产

    bundle exec rake assets:precompile
    
  4. 通过以下命令将应用推送到vmc 。

    vmc push --runtime ruby19
    
于 2013-03-19T19:15:46.407 回答