Sunday, October 10, 2010

Hobo on Heroku

Ok, this was an ordeal that I don't want to have to repeat. So here's how to get your Hobo 1.0.0 app up and running on Heroku.

I'm not going over registering at Heroku or setting up Hobo. I'll presume that you are competent enough to do this yourself with the current guides on their respective sites.
The basics for this post is Tom Locke's recipe at HoboCentral. Also note that the Heroku default server is Aspen (aspen-mri-1.8.6).

So I set up a simple Hobo 1.0.0 app with 1 model. Using ruby 2.3.8, I can test on my app on the development server - no problems.

You will need to add a .gems file in your root directory, that should have all the extra gems that you require. Heroku has a good set, but in order for completeness and futureproofing - add all the ones that you require. Mine looked like this (it will change by the end of this post):

rails -v 2.3.8
will_paginate --version 2.3.11
hobosupport --version 1.0.0
hobofields --version 1.0.0 --ignore-dependencies
hobo --version 1.0.0 --ignore-dependencies

When submitting this to heroku it doesn't start as:
Missing the Rails 2.3.8 gem. Please `gem install -v=2.3.8 rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.

I kept hitting this and there appears to be a problem with Heroku's server of choice 'thin' and hobo and 2.3.8 rails - it will not work with 2.3.8 - this means that you will have to roll back to 2.3.5 to get it up and running. I don't know enough about thin, all I know is that getting the thin gem and trying locally has the same error.

After changing to 2.3.5 in config/environment.rb and .gems:

rails -v 2.3.5
pg --version 0.8.0
will_paginate --version 2.3.11
hobosupport --version 1.0.0
hobofields --version 1.0.0 --ignore-dependencies
hobo --version 1.0.0 --ignore-dependencies

(I also added pg's gem not 100% sure that I need it, but I saw it on heroku's example)

This gets you past the rails problems, only to hit:

/config/initializers/cookie_verification_secret.rb:7: undefined method `cookie_verifier_secret=' for ActionController::Base:Class (NoMethodError)

This seems to be a hobo version error, some new functionality that doesn't work in 2.3.5, my app doesn't require user protection, so I manually edited cookie_verification_secret.rb, commenting out that line.

This is not an ideal solution (in fact I would just call it a hack), you would probably need to step back to an older version of Hobo, I'm hoping to look ahead to Hobo 1.3.x so I'm not worried about finding the correct old hobo version.

Once I did this I was able to:
heroku rake db:migrate

...and finally the app is up and running.

Hope this helps someone.

No comments:

Post a Comment