Reputation: 5618
In Gemfile, I want to write pseudocode:
ruby: '1.9.3' if ENV['HEROKU']
Because I want to run my app on another platform, version like jruby, ruby2.0.0 if !heroku. I think this is heroku specific var, HEROKU_POSTGRESQL_VIOLET_URL
ruby: '1.9.3' if ENV['HEROKU_POSTGRESQL_VIOLET_URL']
What is more better way to do?
Related: How to detect if my app is running on Heroku?
Oops, HEROKU_POSTGRESQL_{VIOLET,SLIVER,RED,...}_URL, this is distributed.
Upvotes: 1
Views: 971
Reputation: 46
It seems to me that if ENV.keys.any? {|var_name| var_name.match(/heroku/i) }
would be a relatively sane approach.
Upvotes: 3
Reputation: 3267
If you don't want to add another environment variable, you could change Rails environment from 'production' to 'heroku' (but it should be done by changing environment variable RAILS_ENV
anyway).
Therefore, locally your Rails environment will be development/test/production, but on Heroku it will be 'heroku' and you'll be able to check:
Rails.env.heroku?
Hope it helps.
Upvotes: -2