darkphantum
darkphantum

Reputation: 531

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?

Upvotes: 0

Views: 236

Answers (1)

Marcelo De Polli
Marcelo De Polli

Reputation: 29291

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.

Upvotes: 1

Related Questions