1
votes

I hope that vcap-service-base of cloudfoundry can visit database of cloud_controller, then I need provisioner.rb in vcap-service-base to require 'active_record'. So I added "gem "activerecord" "in the Gemfile of vcap-service-base and then ran 'bundle install'. In the provisioner.rb, I added "require 'active_record'",while starting cloudfoundry, it always threw an error:in `require': no such file to load -- active_record (LoadError), as below:

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

According to the error, it was LoadError. But when I searched the gem "active_record" in /root/cloudfoundry/.deployments/devbox/deploy/rubies/ruby-1.9.2-p180/lib/ruby/gems/1.9.1/gems, it was there exactly. Now I am confused whether it is the LoadError or I missed something important. Why in vcap-service-base, can "require 'active_record'" not be found ?

1
Have you tried require'./active_record'? - BlackHatSamurai

1 Answers

0
votes

When deploying any rails-3 app on cloud foundry, we need to follow the below steps.

  1. If any gems are using inside the app, they should do bundle package and then again bundle install.

  2. In config/environments/production.rb file, modify the line

    config.serve_static_assets = false 
    

    to

    config.serve_static_assets = true
    
  3. Pre-Compile the assets using the below command

    bundle exec rake assets:precompile
    
  4. Push the app to vmc by following command.

    vmc push --runtime ruby19