Rails 3.0 on Heroku after trying Rails 3.2


So I was playing with Rails this weekend making all sorts of progress until I tried to get it running on Heroku. Everything worked fine locally but a variety of errors plagued me up on the servers.

I figured out 4 main issues i was having

  • Bamboo stack instead of Cedar
  • Rails 3.2 instead of 3.0
  • Forcing a push to Github
  • sqlite3 instead of pg

First off I had updated to the latest Rails version but it seems you need to jump through hoops on Heroku if you want to use the latest and greatest. I also looked at using 3.1 on Heroku but this also wasn’t out of the box. So I opted for the tried and true Rails 3.0 on Heroku/Cedar.

Bamboo stack instead of Cedar

When I setup my app this weekend I just used the default Heroku Create syntax. Many of the tutorials neglect to include the –stack option. So after I figured out I wanted to be on cedar instead of bamboo I created my application  on Heroku using:

$ heroku create --stack cedar

Rails 3.2 instead of 3.0

The only problem was I had updated my local rails version to 3.2 and now I need to roll back to version 3.0.

Well I didn’t need to, I could have used the gem _version_ convention. Specifically the Gem setup has a wrapper for executables like rake and rails. That executable supports a _version_ parameter to specify a particular version . I could have used: $ rails _3.0_ new myProject all the time, but that’s just more things for me to forget and I really just wanted a base setup.

The first thing I needed to do was get Rails 3.0 installed. For that I called:

$ gem install rails --version "3.0"

Once installed 3.2 was still being used so I uninstalled it:

$ gem uninstall rails

Since I had two copies installed at this point it asked me which to uninstall, I choose 3.2

Unfortunately my project was already setup using 3.2 so I had to get it clean up back to 3.0. I could have edited the Gemfile, but again I wanted a clean base setup. I trashed the project and rebuilt it with 3.0 scaffolding.

Forcing a push to Github

I added the remote github repo and tried to push but there were conflicts. I honestly  didn’t care at this point so I forced the push not typically advised but I was running out of patience:

$ git push -f origin master

sqlite3 instead of pg

All good so far now I could deploy

$ git push heroku master

but there were errors. DOH I forgot that they use postgress on Heroku not sqlite3. I wasn’t ready to install postgress locally so I opted for a split DB setup. Again this is not advised, I should be using the same DB locally and in prod. I just wanted to get this running though.

Time to update my Gemfile from

gem 'sqlite3'

To this:

group :development, :test do
 gem 'sqlite3-ruby', :require => 'sqlite3'
end
group :production do
 gem 'pg'
end

Once that’s saved I went back to a little tip about –without production and ran:

$ bundle install --without production

Then I continued with the deployment and ran

$ heroku run rake db:migrate

and everthing worked fine.

Now I can focus on writing the code and not worrying about the environment setup.

Published by cgrant

Christopher Grant is an IT professional with and MBA and over 15 years experience developing technology based business solutions. His work with small business and large corporations includes leading development efforts in a wide variety of domains ranging from internal business systems to externally facing eCommerce systems.

Leave a comment