So, I have been merrily using foreman in my development environment and have been very happy using the environment variables.
So recently I created a new rails project and followed the same mundane procedure and when I did the coveted
it started working just fine and life went on!
Suddenly, I felt the urge to check something in the rails console and I called my friend
foreman run rails c
and it loaded. But when I queried, it gave me an error saying
"Permission denied for relation..."
After a bit of googling and a lot of swearing and cursing, I was filled with frustration as I had no clue what’s happening. Then, I realized that rails console was trying to access the DB not using the env variables I had set but using the default postgres user! Elementary, wasn’t it?
But the this was a shocker as I had no idea what to do now. I was almost ready to go to the church for solving this issue when spring came in my life! Not the season but the preloader gem which is now a default in rails.
As soon as I disabled spring using
my rails console started working like before and life was happy again!
The correct way of solving the issue however is to create a `’config/spring.rb` file with contents
Hope it helps!