The first step of migrating my Rails app to Heroku included only a reduced feature set.
I completely removed all parts dealing with the Amazon-API, because ruby-aaws could not be installed as a gem on Heroku. The ruby-aaws gem is build on Ruby >= 1.8.7 while Heroku is running 1.8.6 #fail.
I asked Ian Macdonald, the creator of ruby-aaws, if there might be a workaround for this problem. Ian told me that this should not be a blocker and pointed me to some things I should take care of.
How to make ruby-aaws run with 1.8.6
Here are the steps that I performed to get things running:
# install gemsonrails to freeze the gem into the app sudo gem install gemsonrails # go to your rails folder cd rails/yourapp # install gemsonrails for your app gemsonrails # freeze the app rake gems:freeze GEM=ruby-aaws
This will freeze the gem into vendor/gems/. Then I removed the tests and the examples, because they are not necessary and contain code that won’t work.
The app won’t start up until I fixed some little load path error:
# vendor/gems/ruby-aaws-0.7.0/init.rb # add amazon to the path require_options = ["ruby-aaws", "ruby/aaws", "amazon"]
The ruby-aaws library expects some login-credentials for the Amazon-API which are usually stored in a ~/.amazonrc file. Since Heroku gives no access to a user home (at least I did not manage to get access to it), I worked around it by putting the file in the RAILS_ROOT and adding some glue code in Amazon::Config:
# vendor/gems/ruby-aaws-0.7.0/lib/amazon.rb # add rails-file config_files << File.join(RAILS_ROOT, '.amazonrc') if defined?(RAILS_ROOT)
The next thing to fix was the usage of String.bytesize, which is not available in 1.8.6:
string.gsub( /([^a-zA-Z0-9_.~-]+)/ ) do # replace .bytesize with .size '%' + $1.unpack( 'H2' * $1.size ).join( '%' ).upcase end