Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save dtinianow/e8dc08dd1ab9c7f343acbb7fe6bab65e to your computer and use it in GitHub Desktop.

Select an option

Save dtinianow/e8dc08dd1ab9c7f343acbb7fe6bab65e to your computer and use it in GitHub Desktop.
How to Run a Rails App in Production Locally
  1. Add gem 'rails_12factor' to your Gemfile. This will add error logging and the ability for your app to serve static assets.
  2. bundle
  3. Go to into database.yml and change username to the name of your computer (type whoami into command line)
  4. Run RAILS_ENV=production rake db:create db:migrate db:seed
  5. Run rake secret and copy the output
  6. From the command line: export SECRET_KEY_BASE=output-of-rake-secret
  7. To precompile your assets, run rake assets:precompile. This will create a folder public/assets that contains all of your assets.
  8. Run RAILS_ENV=production rails s and you should see your app.

Remember to clobber your assets (rake assets:clobber) and re-precompile (rake assets:precompile) if you make changes.

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