0

I am developing a RoR4 app using a Postgre database that does some background database processing with resque and is hosted on Heroku. My question regards running locally for development.

It is my understanding (in this particular project) that when I start the web server using rails server, it connects to a development database, and when I start it using foreman start (with an appropriate Procfile), it connects to some other local database.

My problem is that my Resque jobs look for ActiveRecords in the development database, forcing me to use rails server. However, I need to access some environment variables, stored in a .env file, and it is my understanding that only foreman is able to read these environment variables.

How do I approach a workaround for this problem?

More specifically, how can I get my Resque jobs to look for ActiveRecords in the same database that foreman start uses? Or, how do I have foreman start use the the development database?

My guess for the latter would be edit the Procfile, but I haven't had luck finding a simple solution.

Procfile.dev:

web: bundle exec unicorn -c ./config/unicorn.rb -E $RAILS_DEV

NOTE: $RAILS_DEV=development

Any help would be appreciated. Thanks.

astronomotrous
  • 431
  • 1
  • 3
  • 12

1 Answers1

0

I found out what the problem is. It turns out that my .env file had an explicit URL to connect to my Heroku database. Once I removed that line, foreman start connected to my development database.

astronomotrous
  • 431
  • 1
  • 3
  • 12