I am not writing in Rails. It is just ruby.
But I have a dev environment that has it's own development group in the Gemfile.
But I don't use them in production on Iron.io.
In particular, I use "log_buddy" and have lots of d {var}
statements throughout.
And I use pry
which has a require pry
and require-debug
statement.
These statements create errors in the case of pry
and duplicate logging in the case of log_buddy
when the code runs in production.
How do I make a distinction between the two environments?
I have read about dotenv
and some other gem, but didn't quite understand how it would work in my scenario.
If you have just yes
/no
scenario for dev, dotenv
family is an overkill. I would go with surrounding dev requirements with:
if ENV['DEV']
require 'pry'
...
end
and then run development scenarios as:
DEV=true bundle exec ...
Since DEV
env variable is not defined on your prod server, nothing will be included there.
Init for log_buddy
might look like:
LogBuddy.init(ENV['DEV'] ? {:logger => Logger.new('my_log.log')} : nil)