Search code examples
ruby-on-railsrubyopenshiftproduction

OpenShift NextGen and Rails - An unhandled lowlevel error occurred


I'm an OpenShift newbie and just a while ago I managed to deploy a basic Rails app with the Next Gen console. I did a few tweaks to the app, namely created a home controller with

`rails g controller home index`

and updated the config/routes.rb file by setting the root route to root 'home#index' instead of get 'home/index'. Now the local rails server points correctly to the index page when running in development environment, so there is no problem at all. But when I pushed the updated content to the git remote repository and and started a new build with

oc start-build <app>

and reloaded the page with the OpenShift production environment, nothing is shown but

An unhandled lowlevel error occurred. The application logs may have details.

Edit: the command oc logs dc/<app> returned me this as "root error":

#<RuntimeError: Missing `secret_key_base` for 'production' environment, set this value in `config/secrets.yml`>

Then my config/secrets.yml in the production section reads:

# Do not keep production secrets in the repository,
# instead read values from the environment.
production:
  secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>

Now I guess this has to do with setting up environment variables in an OpenShift environment. I found out the command

oc env dc/<app> <ENV_VARIABLE>=<value>

from this guide. Is it the correct one? If yes, how to generate a proper SECRET_KEY_BASE value?

Any help is of course highly appreciated, thank you


Solution

  • Solved. I found out eventually the rake secret command generates a hash for you, then used oc env dc/<app> SECRET_KEY_BASE=<hash> and rebuilt the app with oc start-build <app>