Be careful the environment you choose
for it will shape you
Michael Hartl mentions in his Rails Tutorial that Rails comes equipped with three environments:
Then an aside shows how to run a console, a server and a rake task in an environment different from the implicit
development because, as he confesses
I find it confusing that the console, server, and migrate commands specify non-default environments in three mutually incompatible ways, which is why I bothered showing all three.
Amongst the minds that cope better with consistent patterns, I also count mine. The trick that seems to save me some brain cycles is easy, almost too obvious. Declare the
RAILS_ENV environment variable right before the command, on the same line. In few cases this becomes slightly less elegant, but at least it's consistent.
For the sake of explicitness, here are the alternatives:
(note: the examples use the
|the mutually incompatible way||the consistent pattern equivalent|
Almost too obvious, you had been warned!
What other quirks do you leverage to save yourself extra brain cycles?
Cover image credit: https://500px.com/photo/105625329/matterhorn-by-%C4%B0lhan-eroglu