How to set Rails environment?

  • Posted on May 26, 2014
  • TintinAsked by Tintin

I have a 1-click installation of Ruby on Rails 4, NginX, and Ubuntu running on my droplet.

Unfortunately, I haven’t found a way to create my production database from my schema.rb file yet.

I think this is due to the fact that my Rails environment is still set to “development”. When I type “rake about” I get this:

Application root /home/rails Environment development Database adapter sqlite3

I would like to set my app to production mode, though. I would also like to use MySQL instead of SQLite.

How can this be done?

Typing “RAILS_ENV=production” seems to have no effect whatsoever.

Thanks for any help.

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Yes, this is what I ended up doing (5 years after posting the initial question) and it seems to work.

More on rbenv-vars can be found here.

I personally use a .rbenv-vars file in the root of each Rails project. There you can set all your project specific env vars and they’re going to be automatically loaded by rbenv.

Good point. Have you found a solution to this yet?