Deploying my first solo Rails app to Heroku

Enough local development. It’s time to push something live. Based on experiences with a couple of other lightweight apps, I’m looking to use Heroku. So what does that entail?

secured payday loans online

To start, I had to get git set up in my project directory and commit the files.  Heroku has some pretty straightforward guidance on this.  However, before creating a “Heroku Remote”, as demonstrated using the command: heroku create –stack cedar, I wanted to understand what else I might need to change.  The “–stack cedar” parameters gave me pause, so I went back to the support section on Heroku to look at the getting started content.  There, I discovered that I needed to make two changes.

The first change would be to get on Ruby 1.9.2.  Not knowing what version I was running, I typed ruby -v and found that I was on 1.8.7 (which happens to be what’s shipped by default on my MacBook Air.  After a google search, I saw some advice to use rvm to manage my versions of Ruby.  Ok, followed the commands and installed 1.9.2.  So far, so good.

Next, I noticed that Heroku uses PostgreSQL.  I’ve been using Mysql to develop locally and was hoping I could just use that in production, but looks like I have to switch.  Ok, I use the One Click installer found here, and add gem ‘pg’ to my Gemfile.  Now, I just need to run bundle install and expect to be all set.  Um, not so fast…

Building native extensions.  This could take a while…
ERROR:  Error installing pg:
    ERROR: Failed to build gem native extension.

        /Users/kmr2/.rvm/rubies/ruby-1.9.2-p318/bin/ruby extconf.rb
checking for pg_config… no
No pg_config… trying anyway. If building fails, please try again with
 –with-pg-config=/path/to/pg_config
checking for libpq-fe.h… no
Can’t find the ‘libpq-fe.h header
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
    –with-opt-dir
    –with-opt-include
    –without-opt-include=${opt-dir}/include
    –with-opt-lib
    –without-opt-lib=${opt-dir}/lib
    –with-make-prog
    –without-make-prog
    –srcdir=.
    –curdir
    –ruby=/Users/kmr2/.rvm/rubies/ruby-1.9.2-p318/bin/ruby
    –with-pg
    –without-pg
    –with-pg-dir
    –without-pg-dir
    –with-pg-include
    –without-pg-include=${pg-dir}/include
    –with-pg-lib
    –without-pg-lib=${pg-dir}/lib
    –with-pg-config
    –without-pg-config
    –with-pg_config
    –without-pg_config

Gem files will remain installed in /Users/kmr2/.rvm/gems/ruby-1.9.2-p318/gems/pg-0.13.2 for inspection.
Results logged to /Users/kmr2/.rvm/gems/ruby-1.9.2-p318/gems/pg-0.13.2/ext/gem_make.out

Well, this looks like fun.  After much searching and trial and error, the answer that worked was in a StackOverflow post on this issue.  But it wasn’t one of the top answers – it was this one:

PATH=$PATH:/Library/PostgreSQL/9.1/bin sudo gem install pg

Ok, enough for this post.  Now I’m going to try switching my dev environment over to PostgreSQL (I don’t want to be using different databases in development than production – no interest in trying to debug any issues that might crop up over time:)



Leave a Reply

Your email address will not be published. Required fields are marked *

Comment

You may use these tags : <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>