Skip to content

Instantly share code, notes, and snippets.

@ksk5280
Last active April 20, 2016 19:19
Show Gist options
  • Save ksk5280/a3c45cdf324a548a50518effc71da99a to your computer and use it in GitHub Desktop.
Save ksk5280/a3c45cdf324a548a50518effc71da99a to your computer and use it in GitHub Desktop.
How to run apps in production locally
  • RAILS_ENV=production rails s
    • this sets the key in the ENV hash
    • you can also set these in different lines
  • Go to "http://localhost:3000/" and you'll see this:
    • Missing secret_token and secret_key_base for 'production' environment, set these values in config/secrets.yml
  • Run rake secret in terminal to generate a key
  • RAILS_ENV=production rake db:{create,migrate}
  • Delete username and password lines from database.yml under production
  • bundle exec rake assets:precompile
  • bundle exec rake assets:clobber

Other tips:

  • You always need to restart server
  • command + K
    • clears log so you can see what the errors are when you rerun
  • gem rails_12factor puts errors into your log
  • tail -f log/development.log (or any file)
    • Any time something gets written to a file, it outputs the text
  • Put database.yml in gitignore

Rachel's instructions: https://gist.github.com/rwarbelow/40bd72b2aee8888d6d91

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment