简体   繁体   中英

Loading rails env in production

I have deployed a new Rails site to a Linux VM using Capistrano. I am using nginx as the front end and running my Rails app using unicorn.

If I try to run rake routes on the server, I get an error telling me that Rails is not installed, even though Rails is installed. The problem seems to be that the gem search directory is different for the app and the logged in user.

How do I load the Rails environment that my app is seeing as the logged in user?

Just use:

RAILS_ENV=production bundle exec rake routes

The RAILS_ENV part sets your environment variable so your app is loaded in full production mode, including database settings and so on.

The bundle exec part is necessary so that any commands that come after that are executed within the environment of the gems installed in your Gemfile.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM