(Disclaimer: New to deploying Sinatra on Heroku.)
I have seen http://www.sinatrarb.com/configuration.html and it tells me to set :environment, :production
. My question is, how can I specify it to do: "when in Heroku, set environment as production, else stay in test/development."
Also, even after putting the line set :environment, :production
, I don't think it is working because when I try to rackup
the app locally, it's still running (when I know (or I think I know) that it shouldn't because I haven't installed postgres on my computer).
Gemfile
group :production do
gem 'dm-postgres-adapter'
end
group :development, :test do
gem 'dm-sqlite-adapter', "~> 1.2.0"
end
The Sinatra environment has nothing to do with the gems inside the production group being loaded. These are separate and don't work with each other.
Sinatra takes the environment from the RACK_ENV
environment variable, just start it with RACK_ENV=production rackup
Bundler works a bit different, you can choose which groups it should exclude when running bundle install: bundle install --without production
Sinatra uses the APP_ENV
environment variable. You can also set it explicitly via settings, as you mentioned.
A symbol specifying the deployment environment; typically set to one of :development, :test, or :production. The :environment defaults to the value of the APP_ENV environment variable (ENV['APP_ENV']), or :development when no APP_ENV environment variable is set.
That is how you tell Sinatra the environment.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With