pass environment variables inside a rake task

If you want to run you rake task without passing the environment variable in the command line argument.

Use Case: The task runs only in production and it needs to be automated.However, we need to pass a command line variable for the task to run.

Following is the task:

namespace :my_task do
   desc "This is a task that runs only in production"
   task :awesome do
      if Rails.env.production?



The command used to run the task is as follows :

$ bundle exec rake my_task:awesome RAILS_ENV="production"

We can achieve this by writing another rake task that passes the environment variable to the respective task(s). In case there are a bunch of other tasks you can define them all under the same task.

namespace :my_main_task do
  desc "Use this to fire other tasks"
  task : do
     Rails.env = "Production"

Or you can make a direct command call:

namespace :orbit do
  desc "display the current environment of rake"
  task :asset do
     Rails.env = "Production"
     system("rake orbit_task:awesome RAILS_ENV=production")

The issue with the second approach is that it will spawn a lot of rake tasks, so the first approach seems better.

I read Counter Clock World by Philip K Dick long back. But recently I made a visit to it. The thing that I deduced from it was quite a surprise and I could then see what great vision he had of a future society. Despite the fact that his story is based in a future time and is about time reversal, there are two things which really struck me were unique and that made me connect it to today’s times.

The first and foremost thing. Liberary is the most powerful body in the world. What Philip K Dick saw coming was the fact that infomation about everyhing in the world is the key to world domination. Liberary is so powerful that it can track people’s where abouts, trace their calls , and eventually topple the governments. Though they are not the actual rulers, they still hold all the power. People come to liberary to “Search” information. Now does that ring a bell ? PKD has always, critcized or rather shown his displeasure towards a centralized authority system also technically known as a “Totalian Society”.

The second and also something that has been there since ages but really took an ugly turn in the late 80s, 90s and 2000s, is Religion. The book talks about a Religion called Udi, which is on the lines of spirituality and god as an entity of the universe. However, it loses it’s direction and ends up dividing the society and the country into different parts. The founder of Religion is old-born (Due to the time reversal in the book) and when he comes to life, he realizes, the religion he founded has lost it’s direction and purpose.

Both the concepts are pretty futuristic to the time the book was written in 1967. There was no google or internet but envisioned the information to flow freely and extremely fast in the futuristic world. Aren’t both the concepts so true in today’s world ? Google and Web in general is a single point of authority that controls most of our life and religions, aren’t they rotting the world and themselves anyway ?


So they say life’s a journey, not a destination,

and I feel the same when the train arrives on this station,

if there is no destination, I ask myself,

why this whole journey itself,

And I board the train,

which these questions in my brain,

When I see the sun setting in the distance, clearing cloud and passing rain,

When I see the train bending into the tunnel like being eaten by mountain,

I realize, there are no destinations, 

there are just horizons,

Our journey is just from one horizon to another,

Into the infinity of unknown, I would savour this journey, than fear rather

Wait for the morning light

When the road unfolds in front of my eyes,

and horizon lets me in to the unknown,

as the sound of my ride, fills the silence of my thoughts,

a day ends into the twilight and darkness becomes known,

The edge of the hill, feels like the end of the world,

the lights down there seem like a hope yet to be shown,

a moment, an hour, a day a year passes,

a laugh , a tear , an experience, a broken resolution, a serendipitous happening, an unfulfilled emotion, a magical potion,a life worth living , you think is gone ?

the morning beckons, a new beginning awaits,

as the road unfolds, into an unknown waiting to be known

the door of light

feeling the corridor, blinded by darkness,

closed my eyes, and walked with tenderness,

I could find my ground but was not sure,

all this while, I was looking the right door,

the door to freedom, the door of light,

the door to the world, that would bring me sight,

a gulp of fear, whether or not I am right ?

My eyes adjust to dark, and then I see the way,

at the end of the path , I see across the floor,

ray of light breaking through, small holes in the door,

and that was the moment of truth, the darkness seemed suddenly white,

I smiled, I rose to my feet and ran, towards the door of light

Unknown traveler

An unknown traveler,

a lonely road,

Beyond the horizon is where I have to go,

into the realm of unkown, unseen,unfelt

Stopping is not an option,

fear is meant to be contempt,

I get flood, famine , storm and rain,

and In my heart I feel the pain,

sometimes i feel like falling into infinity,

but you see infinity is a part of me,

I pray to see sunshine,

and rekindle the hope as it is mine,

I see the other traveler’s in pain,

and lend them a helping hand without refrain,

I will not wait for the dark night to pass,

and keep working till the dawn breaks,

Then i follow the next horizon,

And set out again,

I am just an An unknown traveler,

on a lonely road


I sleep with open eyes,

and dream with them too,

I dream of open skies,

and streams of love too,

I breath the air of life,

and taste the mud with it,

In my heart I keep an elise,

to smile and be happy galore,

to all the made and broken ties,

I see them coming together at the horizon for sure,

and i dream again with open eyes,

listening to endless, stretched ocean, from the life’s shore