문제

I am using RVM with Foreman with Rails 3.2. I have an .env file in my app root directory, which was supposed to be loaded with Foreman. But apparently it couldn't load rails when I use ENV['DATABASE_NAME'] in database.yml. But strangely, after rails is loaded using hardcoded database name, I could open up console and access the ENV['DATABASE_NAME']. And Foreman really can't access ENV in its Procfile either. I have another rails 4 app that could access ENV in devise.rb, which is one of the initializer, but when I put the same ENV['DATABASE_NAME'] in database.yml, it will start the server ok, but not able to open a page when the app is trying to access the database. So it looks like the ENV is only loaded by rails, after rails itself is loaded. How do you allow it also be accessible by Procfile and database.yml.

도움이 되었습니까?

해결책

If you show examples of your Profile and .env it would be be easier for someone to help out.

My wild guess from your question is you are using the env variables incorrectly in the Procfile.

If for example in .env you have PORT=3000

then in your Profile it's referred to as $PORT -- not as ENV['PORT']

In a ruby file such as a config initializer you WOULD use ENV['FOO']

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top